CN109901841A - A method of display methods call graph when checking java bytecode - Google Patents
A method of display methods call graph when checking java bytecode Download PDFInfo
- Publication number
- CN109901841A CN109901841A CN201910154271.5A CN201910154271A CN109901841A CN 109901841 A CN109901841 A CN 109901841A CN 201910154271 A CN201910154271 A CN 201910154271A CN 109901841 A CN109901841 A CN 109901841A
- Authority
- CN
- China
- Prior art keywords
- file
- node
- code
- display methods
- call
- 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
Landscapes
- Stored Programmes (AREA)
Abstract
The invention discloses it is a kind of check java bytecode when display methods call graph method, comprising the following steps: one, jar file is decompressed, dis-assembling is carried out to class file therein, generates corresponding code text file;Two, text analyzing is carried out to code text file, parses all methods in all classes, and each method is set as the node in a topological structure;Three, the method call code in each method is analyzed, the method for finding calling, association is established in topological diagram;Four, according to topological diagram, each node is used to unified graphic plotting, and connecting node in the picture;Five, mouse clicking trigger event handling function is added for each node figure in the picture, when the user clicks when figure, processing function, which automatically opens the file where method and jumps to method, defines corresponding line number.Automatic logic analysis and generating function relationship calling figure are realized to the class file decompiling bytecode of java, are graphically presented to developer.
Description
Technical field
The present invention relates to a kind of code logic analysis methods, and in particular to display methods tune when one kind checks java bytecode
With the method for relational graph.
Background technique
There is the tool such as IDA that decompiling is much carried out to executable file in software decompilation field at present, also has to Java
The decompiling instrument such as JD-gui that the intermediate code file of code building carries out.Directly required using executable file decompiling instrument
Developer is higher to computer expertise grounding in basic skills, can understand assembler language, machine code, computer addressing working principle, height
Calling convention of function when grade language compilation, stacking, out stack mode.And human nature directly is wanted to the decompiling of network compiler language JAVA
Change many, if JD-gui can decompile into jar file java source file, convenient for being directly viewable JAVA source file.But due to generation
The appearance of code obfuscation, can allow JD-gui related tool information loss, code logic occur when carrying out decompiling to jar file
Mistake.Bytecode memonic symbol is directly analyzed so sometimes needing directly to pass through JAVA dis-assembling.Since present software is all big
Type project, if directly by text compiler checking the obvious inefficiency of bytecode memonic symbol, when being not easy to check code
Method jumps between function call.Along with the inclined bottom of bytecode memonic symbol itself and machine code correspond, unlike advanced
For language close to natural language, therefore, it is difficult to read.If so being able to achieve some easy-to-read codes of code reading tool
Function allows computer help code analysis personnel to complete a part of work.The figure of visual representation code hierarchical relationship can be generated
Expression is presented to analysis personnel.
IDA advantage is the machine code that energy directly dis-assembling goes out software, the class file including executable file and java.
Function call relationship graph and flow chart branches figure can be automatically generated.The disadvantage is that cannot class file generated function call to java
Relational graph.
JD-gui advantage be can the class file to java decompile into java source code, the disadvantage is that cannot be to each class
File all decompiles into java source code, part decompiling code or command byte code.It is unable to generating function call graph, is allowed
The reading of command byte code becomes trouble.
Summary of the invention
The purpose of the present invention is to provide it is a kind of check java bytecode when display methods call graph method, provide
It is a kind of to fast implement quickly jumping between the method function that is mutually related in different files when browsing java bytecode
Method, code when improving reverse-engineering check efficiency.
In order to solve the above technical problems, the invention adopts the following technical scheme:
A method of display methods call graph when checking java bytecode includes the following steps one, to jar file
It is decompressed, dis-assembling is carried out to class file therein, generates corresponding code text file;
Step 2: carrying out text analyzing to code text file, all methods in all classes are parsed, and by each side
Method is set as the node in a topological structure;
Step 3: analyzing the method call code in each method, the method for finding calling, and in topological diagram
Establish association;
Step 4: according to topological diagram, each node used to unified graphic plotting in the picture, and with line segment with the arrow
Connecting node, because can have multiple places to call other methods in method, a tubercle can be connected with how many arrow
Other nodes;
Step 5: mouse clicking trigger event handling function is added for each node figure in the picture, when the user clicks
When figure, processing function, which automatically opens the file where method and jumps to method, defines corresponding line number.
Further technical solution is decompressed in the step 1, to jar file, to class file therein into
Row dis-assembling generates corresponding code text file, and the specific method is as follows:
A, it is decompressed in program using the jar file that decompiling is treated in the open source library Zip, and content is put into a catalogue;
B, the java byte code files of all entitled class of suffix in file scan catalogue are realized;
C, assembly code successively is generated using javap order dis-assembling to each bytecode class file and protects code
It is stored to class file position and takes unified file suffixes name.
Further technical solution is, Step 2: carrying out text analyzing to code text file, to parse in all classes
All methods, and each method is set as the node in a topological structure, it is specific as follows:
A, the code text file that compilation generates successively is opened, and carries out text resolution according to specific template;
B, by each method name in each file inside class, method signature, method is realized to be recorded as a data, and
It is abstracted into a node of topological structure.
Further technical solution is, the method name and method signature are combined into the unique identification of each node.
Further technical solution is, described Step 3: analyze the method call code in each method, finds
The method of calling, and association is established in topological diagram, it is specific as follows:
A, to the institute for finding out this method realization in the method realization of each back end generated in b step in step 2
There is method call;
B, each method call is also made of method name and method signature, and is centainly had the unique identification of a node and be somebody's turn to do
Method call is identical, is connected to identifier and the identical other nodes of method call by the method call in each tubercle, closes
Connection forms topological diagram interior joint.
Further technical solution is that in step 4, graphic plotting is the drawing interface (windows by operating system
GDI, the KDE of DX, linux, GNOME, the painting canvas Canvas of Android) or browser interface is on a computer display
Topological diagram in step 3b is rendered to come.
Further technical solution is, Step 5: node pel each in topological diagram is increased mouse click event processing
Function, or be the hyperlink of html under browser, it is directly linked to assembling file line number.
Further technical solution is, if it is event handling function, when the user clicks the mouse, program to be allowed directly to open
Line number where file corresponding to node.
Compared with prior art, the beneficial effects of the present invention are: the class file decompiling bytecode to java is realized certainly
Dynamic logic analysis and generating function relationship calling figure, and it is graphically presented to developer, allow developer to pass through a little
The functional digraph symbol hit on figure can jump to respective function bytecode and analyze and read.
Detailed description of the invention
Fig. 1 is flow chart of the invention.
Fig. 2 is one of the template example that text resolution is carried out in step 2 of the present invention.
Fig. 3 is one of the topological diagram example being made of in step 3 of the present invention method name and method signature.
Fig. 4 is that one of illustrated example is rendered in step 5 of the present invention.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
Fig. 1-Fig. 4 shows following embodiment
Embodiment 1:
A method of display methods call graph when checking java bytecode includes the following steps one, to jar file
It is decompressed, dis-assembling is carried out to class file therein, generates corresponding code text file;
Step 2: carrying out text analyzing to code text file, all methods in all classes are parsed, and by each side
Method is set as the node in a topological structure;
Step 3: analyzing the method call code in each method, the method for finding calling, and in topological diagram
Establish association;
Step 4: according to topological diagram, each node used to unified graphic plotting in the picture, and with line segment with the arrow
Connecting node, because can have multiple places to call other methods in method, a tubercle can be connected with how many arrow
Other nodes;
Step 5: mouse clicking trigger event handling function is added for each node figure in the picture, when the user clicks
When figure, processing function, which automatically opens the file where method and jumps to method, defines corresponding line number.
Embodiment 2:
The present embodiment is compared to embodiment 1, and difference is decompressed in the step 1, to jar file, to therein
Class file carries out dis-assembling, generates corresponding code text file, the specific method is as follows:
A, it is decompressed in program using the jar file that decompiling is treated in the open source library Zip, and content is put into a catalogue;
B, the java byte code files of all entitled class of suffix in file scan catalogue are realized;
C, assembly code successively is generated using javap order dis-assembling to each bytecode class file and protects code
It is stored to class file position and takes unified file suffixes name.
Embodiment 3:
For the present embodiment compared to embodiment 2, difference is parsed Step 2: to the progress text analyzing of code text file
All methods in all classes, and each method is set as the node in a topological structure, it is specific as follows:
A, the code text file that compilation generates successively is opened, and carries out text resolution according to specific template;
B, by each method name in each file inside class, method signature, method is realized to be recorded as a data, and
It is abstracted into a node of topological structure.
As a preferred embodiment of embodiment 3, the method name and method signature are combined into unique mark of each node
Know.
Embodiment 4:
For the present embodiment compared to embodiment 2, difference is Step 3: dividing the method call code in each method
Analysis, the method for finding calling, and association is established in topological diagram, it is specific as follows:
A, to the institute for finding out this method realization in the method realization of each back end generated in b step in step 2
There is method call;
B, each method call is also made of method name and method signature, and is centainly had the unique identification of a node and be somebody's turn to do
Method call is identical, is connected to identifier and the identical other nodes of method call by the method call in each tubercle, closes
Connection forms topological diagram interior joint.
Embodiment 5:
The present embodiment is compared to embodiment 1, difference, and in step 4, graphic plotting is connect by the drawing of operating system
Mouth (GDI of windows, DX, the KDE of linux, GNOME, the painting canvas Canvas of Android) or browser interface are calculating
The topological diagram in step 3b is rendered on machine display.
Embodiment 6:
For the present embodiment compared to embodiment 1, difference is clicked Step 5: node pel each in topological diagram is increased mouse
Event handling function, or be the hyperlink of html under browser, it is directly linked to assembling file line number.
As a preferred embodiment of embodiment 6, if it is event handling function, when the user clicks the mouse, make program straight
Connect the line number where file corresponding to opened nodes.
Highly preferred embodiment of the present invention is:
A method of display methods call graph when checking java bytecode includes the following steps one, to jar file
It is decompressed, dis-assembling is carried out to class file therein, generates corresponding code text file;
A, it is decompressed in program using the jar file that decompiling is treated in the open source library Zip, and content is put into a catalogue;
B, the java byte code files of all entitled class of suffix in file scan catalogue are realized;
C, assembly code successively is generated using javap order dis-assembling to each bytecode class file and protects code
It is stored to class file position and takes unified file suffixes name;
Step 2: carrying out text analyzing to code text file, all methods in all classes are parsed, and by each side
Method is set as the node in a topological structure;
A, the code text file that compilation generates successively is opened, and carries out text resolution according to specific template;
B, by each method name in each file inside class, method signature, method is realized to be recorded as a data, and
It is abstracted into a node of topological structure, the method name and method signature are combined into the unique identification of each node;
Step 3: analyzing the method call code in each method, the method for finding calling, and in topological diagram
Establish association;
A, to the institute for finding out this method realization in the method realization of each back end generated in b step in step 2
There is method
It calls;
B, each method call is also made of method name and method signature, and is centainly had the unique identification of a node and be somebody's turn to do
Method call is identical, is connected to identifier and the identical other nodes of method call by the method call in each tubercle, closes
Connection forms topological diagram interior joint;
Step 4: according to topological diagram, each node used to unified graphic plotting in the picture, and with line segment with the arrow
Connecting node, because can have multiple places to call other methods in method, a tubercle can be connected with how many arrow
Other nodes;
The graphic plotting on a computer display will by the drawing interface or browser interface of operating system
Topological diagram in step 3b, which renders, to be come;
Step 5: mouse clicking trigger event handling function is added for each node figure in the picture, when the user clicks
When figure, processing function, which automatically opens the file where method and jumps to method, defines corresponding line number;If it is event handling
Function allows line number where file corresponding to the direct opened nodes of program when the user clicks the mouse.
Although reference be made herein to invention has been described for multiple explanatory embodiments of the invention, however, it is to be understood that
Those skilled in the art can be designed that a lot of other modification and implementations, these modifications and implementations will fall in this Shen
It please be within disclosed scope and spirit.More specifically, disclose in the application, drawings and claims in the range of, can
With the building block and/or a variety of variations and modifications of layout progress to theme combination layout.In addition to building block and/or layout
Outside the modification and improvement of progress, to those skilled in the art, other purposes also be will be apparent.
Claims (8)
1. a kind of method of display methods call graph when checking java bytecode, it is characterised in that include the following steps one,
Jar file is decompressed, dis-assembling is carried out to class file therein, generates corresponding code text file;
Step 2: carrying out text analyzing to code text file, all methods in all classes are parsed, and each method is set
The node being set in a topological structure;
Step 3: analyzing the method call code in each method, the method for finding calling, and established in topological diagram
Association;
Step 4: each node to be used to unified graphic plotting, and connecting node in the picture according to topological diagram;
Step 5: mouse clicking trigger event handling function, when the user clicks figure is added for each node figure in the picture
When, processing function, which automatically opens the file where method and jumps to method, defines corresponding line number.
2. a kind of method of display methods call graph when checking java bytecode according to claim 1, feature
It is: is decompressed in the step 1, to jar file, dis-assembling is carried out to class file therein, generates corresponding generation
Code text file, the specific method is as follows:
A, it is decompressed in program using the jar file that decompiling is treated in the open source library Zip, and content is put into a catalogue;
B, the java byte code files of all entitled class of suffix in file scan catalogue are realized;
C, assembly code successively is generated using javap order dis-assembling to each bytecode class file and is saved in code
Class file position simultaneously takes unified file suffixes name.
3. a kind of method of display methods call graph when checking java bytecode according to claim 2, feature
It is: Step 2: carrying out text analyzing to code text file, parses all methods in all classes, and by each method
The node being set as in a topological structure, specific as follows:
A, the code text file that compilation generates successively is opened, and carries out text resolution according to specific template;
B, by each method name in each file inside class, method signature, method is realized to be recorded as a data, and is abstracted
At a node of topological structure.
4. a kind of method of display methods call graph when checking java bytecode according to claim 3, feature
Be: the method name and method signature are combined into the unique identification of each node.
5. a kind of method of display methods call graph when checking java bytecode according to claim 3, feature
It is: it is described Step 3: analyze the method call code in each method, the method for finding calling, and in topological diagram
Middle foundation association, specific as follows:
A, to all sides for finding out this method realization in the method realization of each back end generated in b step in step 2
Method is called;
B, each method call is also made of method name and method signature, and centainly has the unique identification and this method of a node
It calls identical, identifier and the identical other nodes of method call is connected to by the method call in each tubercle, are associated with shape
At topological diagram interior joint.
6. a kind of method of display methods call graph when checking java bytecode according to claim 1, feature
Be: in step 4, graphic plotting be by the drawing interface or browser interface of operating system on a computer display
Topological diagram in step 3b is rendered to come.
7. a kind of method of display methods call graph when checking java bytecode according to claim 1, feature
It is: Step 5: node pel each in topological diagram is increased mouse click event processing function, or is under browser
The hyperlink of html is directly linked to assembling file line number.
8. a kind of method of display methods call graph when checking java bytecode according to claim 7, feature
It is: if it is event handling function, when the user clicks the mouse, allows where file corresponding to the direct opened nodes of program
Line number.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910154271.5A CN109901841B (en) | 2019-03-01 | 2019-03-01 | Method for displaying method calling relation diagram during viewing of java byte codes |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910154271.5A CN109901841B (en) | 2019-03-01 | 2019-03-01 | Method for displaying method calling relation diagram during viewing of java byte codes |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109901841A true CN109901841A (en) | 2019-06-18 |
CN109901841B CN109901841B (en) | 2022-02-18 |
Family
ID=66946023
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910154271.5A Active CN109901841B (en) | 2019-03-01 | 2019-03-01 | Method for displaying method calling relation diagram during viewing of java byte codes |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109901841B (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110675256A (en) * | 2019-08-30 | 2020-01-10 | 阿里巴巴集团控股有限公司 | Method and device for deploying and executing intelligent contracts |
CN111008022A (en) * | 2019-12-04 | 2020-04-14 | 浙江大搜车软件技术有限公司 | Relationship graph generation method and device, computer equipment and storage medium |
CN111242360A (en) * | 2020-01-07 | 2020-06-05 | 国网安徽省电力有限公司合肥供电公司 | Method for supporting online analysis and offline editing of power grid topological graph |
US10783082B2 (en) | 2019-08-30 | 2020-09-22 | Alibaba Group Holding Limited | Deploying a smart contract |
CN113110842A (en) * | 2020-07-08 | 2021-07-13 | 马森 | Software bytecode homology analysis method, device and equipment |
CN113312038A (en) * | 2021-06-18 | 2021-08-27 | 浪潮云信息技术股份公司 | Implementation method for generating Java code class relay structure |
CN113626017A (en) * | 2021-07-06 | 2021-11-09 | 曙光信息产业(北京)有限公司 | Heterogeneous program analysis method and device, computer equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103473509A (en) * | 2013-09-30 | 2013-12-25 | 清华大学 | Android platform malware automatic detecting method |
CN103873277A (en) * | 2012-12-12 | 2014-06-18 | 中国科学院声学研究所 | Layered network topology visualizing method and system |
US20160283207A1 (en) * | 2015-03-27 | 2016-09-29 | Ca, Inc. | Co-existential wrapping system for mobile applications |
CN106933645A (en) * | 2017-01-17 | 2017-07-07 | 深圳市能信安科技股份有限公司 | A kind of Apk security risks automatic Static auditing system and method |
CN108021411A (en) * | 2017-12-06 | 2018-05-11 | 国网江苏省电力有限公司电力科学研究院 | A kind of discovery system of calling service relation and discovery method |
-
2019
- 2019-03-01 CN CN201910154271.5A patent/CN109901841B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103873277A (en) * | 2012-12-12 | 2014-06-18 | 中国科学院声学研究所 | Layered network topology visualizing method and system |
CN103473509A (en) * | 2013-09-30 | 2013-12-25 | 清华大学 | Android platform malware automatic detecting method |
US20160283207A1 (en) * | 2015-03-27 | 2016-09-29 | Ca, Inc. | Co-existential wrapping system for mobile applications |
CN106933645A (en) * | 2017-01-17 | 2017-07-07 | 深圳市能信安科技股份有限公司 | A kind of Apk security risks automatic Static auditing system and method |
CN108021411A (en) * | 2017-12-06 | 2018-05-11 | 国网江苏省电力有限公司电力科学研究院 | A kind of discovery system of calling service relation and discovery method |
Non-Patent Citations (1)
Title |
---|
赵丹: "《基于静态类型分析的Java程序函数调用图构建方法研究》", 《中国优秀硕士学位论文全文数据库信息科技辑》 * |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110675256A (en) * | 2019-08-30 | 2020-01-10 | 阿里巴巴集团控股有限公司 | Method and device for deploying and executing intelligent contracts |
US10783082B2 (en) | 2019-08-30 | 2020-09-22 | Alibaba Group Holding Limited | Deploying a smart contract |
US11010303B2 (en) | 2019-08-30 | 2021-05-18 | Advanced New Technologies Co., Ltd. | Deploying a smart contract |
US11307990B2 (en) | 2019-08-30 | 2022-04-19 | Advanced New Technologies Co., Ltd. | Deploying a smart contract |
CN111008022A (en) * | 2019-12-04 | 2020-04-14 | 浙江大搜车软件技术有限公司 | Relationship graph generation method and device, computer equipment and storage medium |
CN111008022B (en) * | 2019-12-04 | 2023-12-12 | 浙江大搜车软件技术有限公司 | Relationship diagram generation method, device, computer equipment and storage medium |
CN111242360A (en) * | 2020-01-07 | 2020-06-05 | 国网安徽省电力有限公司合肥供电公司 | Method for supporting online analysis and offline editing of power grid topological graph |
CN113110842A (en) * | 2020-07-08 | 2021-07-13 | 马森 | Software bytecode homology analysis method, device and equipment |
CN113312038A (en) * | 2021-06-18 | 2021-08-27 | 浪潮云信息技术股份公司 | Implementation method for generating Java code class relay structure |
CN113312038B (en) * | 2021-06-18 | 2022-05-31 | 浪潮云信息技术股份公司 | Implementation method for generating Java code class relay structure |
CN113626017A (en) * | 2021-07-06 | 2021-11-09 | 曙光信息产业(北京)有限公司 | Heterogeneous program analysis method and device, computer equipment and storage medium |
CN113626017B (en) * | 2021-07-06 | 2023-10-31 | 曙光信息产业(北京)有限公司 | Heterogeneous program analysis method, heterogeneous program analysis device, computer equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN109901841B (en) | 2022-02-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109901841A (en) | A method of display methods call graph when checking java bytecode | |
CN107832619B (en) | Automatic application program vulnerability mining system and method under Android platform | |
US7478366B2 (en) | Debugger and method for debugging computer programs across multiple programming languages | |
Heitkötter et al. | Cross-platform model-driven development of mobile applications with md2 | |
US9268539B2 (en) | User interface component | |
US20120151437A1 (en) | Method for translating a cobol source program into readable and maintainable program code in an object oriented second programming language | |
Milano | Android application testing guide | |
US11126527B2 (en) | Software engineering method including tracing and visualizing | |
Chen et al. | A refined decompiler to generate C code with high readability | |
Price | C# 10 and. NET 6–Modern Cross-Platform Development: Build apps, websites, and services with ASP. NET Core 6, Blazor, and EF Core 6 using Visual Studio 2022 and Visual Studio Code | |
St-Amour et al. | Feature-specific profiling | |
Irwin et al. | Object oriented metrics: Precision tools and configurable visualisations | |
CN104915199B (en) | A kind of method and apparatus that Flash projects are converted to Html5 projects | |
CN113934429A (en) | Design draft conversion method and device, computer equipment and storage medium | |
Nguyen et al. | Varis: IDE support for embedded client code in PHP web applications | |
Blundell et al. | Learning android application testing | |
Campbell et al. | Introduction to compiler construction in a Java world | |
Paakki et al. | Automated hypertext support for software maintenance | |
Floch et al. | Model-driven engineering and optimizing compilers: A bridge too far? | |
Oda et al. | Viennatalk and assertch: building lightweight formal methods environments on pharo 4 | |
CN112596737A (en) | Method, system, equipment and storage medium for scanning function call relation | |
Vasani | Roslyn Cookbook | |
Grover | Programming with Java: a multimedia approach | |
Wiedijk | Code Instrumentation with Mod-BEAM | |
Duldulao et al. | Spring Boot and Angular: Hands-on full stack web development with Java, Spring, and Angular |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |