Information processing apparatus, information processing method, and program

By adding annotations and generating additional code to define object generation, the information processing device enhances the accuracy of call graph generation in programs using application frameworks, addressing the challenge of inaccurate static analysis due to undefined dependencies.

JP2024142695AActive Publication Date: 2024-10-11NS SOLUTIONS CORPORATION
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
JP2023054946
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-03-30
Publication Date
2024-10-11
Estimated Expiration
2043-03-30

AI Technical Summary

Technical Problem

In programs created using application frameworks, dependencies between objects are not explicitly defined in the source code, making it difficult to perform accurate static analysis such as pointer analysis, which results in an inaccurate call graph.

Method used

An information processing device that modifies the source code by adding annotations and generating additional code to explicitly define object generation, allowing for a more accurate call graph generation through static analysis.

Benefits of technology

The solution enables the generation of a call graph that closely matches the actual program execution, improving the accuracy of static analysis in programs using application frameworks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

To generate a call graph of a source code which is to be statically analyzed, in a more favorable mode.SOLUTION: An information processing apparatus includes: extraction means which extracts a first source code, of a series of source codes, in which a first field of an object is specified, on the basis of at least one of an annotation indicating generation of an object in the source code and a definition of the object in a setting file associated with the series of a source code; and generation means which generates a second source code in which a code is specified for directly indicating generation of an object corresponding to the first field, the second source code being different from the first source code, and an execution code which calls a process to refer to the first field specified in the first source code by calling a process specified in the second source code. A call graph is generated on the basis of the first source code, the second source code, and the execution code.SELECTED DRAWING: Figure 7
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present disclosure relates to an information processing device, an information processing method, and a program. [Background technology]

[0002] In developing or maintaining a program, in order to understand the program, the source code of the program may be analyzed and the results of the analysis may be used. One of the known methods of source code analysis is called pointer analysis, which analyzes how objects generated in a program are propagated. As data output as a result of pointer analysis, for example, data showing the call relationships between objects, called a call graph, is known.

[0003] Furthermore, in recent years, in order to develop programs more efficiently, there have been an increasing number of cases where templates having numerous reusable program parts, also known as application frameworks, are used. [Prior art documents] [Patent documents]

[0004] [Patent Document 1] International Publication No. 2022 / 123763 Summary of the Invention [Problem to be solved by the invention]

[0005] On the other hand, in a program created using an application framework, the application framework configures dependencies between objects when the program is executed. Therefore, when a program is created using an application framework, the code showing the creation of objects may not be explicitly specified in the source code. In such a case, it may be difficult to perform an accurate analysis using so-called static analysis methods such as pointer analysis.

[0006] To address the above-mentioned issues, Patent Document 1 discloses an example of a technique for generating a call graph using information related to Dependency Injection (DI). However, the technique disclosed in Patent Document 1 does not necessarily generate an accurate call graph (a call graph that is more in line with reality) because it does not perform pointer analysis.

[0007] In view of the above problems, an object of the present invention is to enable a call graph of source code that is the subject of static analysis to be generated in a more suitable manner. [Means for solving the problem]

[0008] The information processing device of the present invention comprises an extraction means for extracting a first source code in which a first field of an object is defined based on at least one of an annotation added to a source code that suggests the generation of an object and a definition of the object in a configuration file associated with the series of source codes to be analyzed, and a generation means for generating a second source code that is different from the first source code and in which a code that directly indicates the generation of an object corresponding to the first field is defined, and an execution code that invokes a process that references the first field defined in the first source code by invoking a process defined in the second source code, and a call graph is generated based on the first source code, the second source code, and the execution code. Effect of the Invention

[0009] According to the present invention, it is possible to generate a call graph of source code that is the subject of static analysis in a more suitable manner. [Brief description of the drawings]

[0010] [Figure 1]FIG. 2 is a diagram for explaining an overview of functions of an information processing device. [Diagram 2] FIG. 11 is a diagram illustrating an example of a method for updating source code. [Diagram 3] FIG. 2 is a diagram illustrating an example of a hardware configuration of an information processing device. [Figure 4] FIG. 2 is a functional block diagram showing an example of a functional configuration of an information processing device. [Diagram 5] 11 is a flowchart showing an example of processing by an information processing device. [Figure 6] FIG. 2 illustrates an example of a source code to be analyzed and its call graph. [Figure 7] FIG. 13 is a diagram illustrating an example of a method for identifying source code and code to be updated. [Figure 8] FIG. 13 is a diagram illustrating an example of an updated source code. [Figure 9] FIG. 13 is a diagram showing an example of a generated call graph. [Figure 10] FIG. 2 illustrates an example of source code to be analyzed. [Figure 11] FIG. 13 is a diagram showing an example of source code to be added. [Figure 12] FIG. 13 is a diagram showing an example of a generated execution code. [Figure 13] FIG. 13 is a diagram showing an example of a generated call graph. [Figure 14A] FIG. 13 is a diagram illustrating an example of a case where a singleton is not applied. [Figure 14B] FIG. 13 is a diagram showing an example in which a singleton is applied. [Figure 15] FIG. 13 is a diagram for explaining consideration of singletons. [Figure 16] FIG. 13 is a diagram illustrating an example of a mechanism for determining whether or not a singleton can be applied. [Figure 17] FIG. 13 is a diagram illustrating an example of a mechanism for determining whether or not a singleton can be applied. [Figure 18] FIG. 11 is a diagram illustrating an example of a method for updating source code. [Figure 19] FIG. 11 is a diagram illustrating an example of a method for generating an execution code. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0011] Hereinafter, preferred embodiments of the present disclosure will be described in detail with reference to the accompanying drawings. In this specification and the drawings, components having substantially the same functional configurations are denoted by the same reference numerals, and redundant description will be omitted.

[0012] <First embodiment> An information processing device according to a first embodiment of the present disclosure will be described below. First, an overview of the functions of the information processing device according to the present embodiment will be described with reference to Figs. As described above, there are some programs, such as those created using an application framework, in which dependencies between objects are configured by the application framework when the program is executed. In such programs, the code indicating the creation of an object may not be explicitly specified in the source code. For example, Figure 1 shows an example of a case in which the code indicating the creation of an object is not explicitly specified in the source code.

[0013] Specifically, source code C111 shown in Fig. 1(a) prescribes, within the code of class X, a field C112 of an object of class B and code C113 for calling a process (method) of the object held in field C112. Fig. 1(b) shows an example of a call graph showing the calling relationships between objects when a program of source code such as that shown in Fig. 1(a) is executed under such a premise. On the other hand, in pointer analysis, which analyzes the calling relationships between objects based on source code without executing the program, field C112 is treated as Null because the creation of an object for that field is not explicitly specified. Therefore, when attempting to generate a call graph for source code C111 using pointer analysis (static analysis), a call graph that does not match the reality may be generated, as shown in Figure 1(c), which is based on the assumption that an object of class B has not been created.

[0014] In consideration of the above situation, the information processing device according to this embodiment makes it possible to generate a call graph that is more in line with the actual situation by making partial modifications to the source code to be analyzed and updating the source code to source code for pointer analysis (static analysis). For example, Fig. 2 is an explanatory diagram for explaining an overview of the functions of the information processing device according to this embodiment.

[0015] FIG. 2(a) shows an example of an update result of source code to be analyzed by the information processing device 100 according to the present embodiment. Specifically, project C331 is a schematic representation of a project (management unit) for managing a series of source codes to be analyzed. The example shown in FIG. 2(a) shows a state after a part of source codes included in project C331 is corrected by the information processing device 100. Note that, for convenience, the example shown in FIG. 2(a) shows an excerpt of a part of source codes that are particularly important among a series of source codes included in project C331. In addition, project C332 is a schematic representation of a project generated by the information processing device 100 separately from project C331 to be analyzed. Project C332 includes an execution code (a code in which a so-called Main class is specified) that calls a process specified in the updated source code included in project C331, and the like.

[0016] In some frameworks, annotations are added to parts that configure dependencies between objects at run time. Based on the annotations, the information processing device 100 according to the present embodiment identifies source code to be updated from a series of source codes designated as analysis targets, and code (e.g., fields) to be updated in the source code. Then, based on a definition of the code to be updated, the information processing device 100 modifies the code.

[0017] For example, in the example shown in FIG. 2(a), an annotation C333 indicated by a keyword "@Autowired" that means that a dependency between objects is formed at run time is added to a field C335 of a part of source code included in a project C331. The information processing device 100 extracts the source code to which a predetermined annotation C333 is added as source code to be updated, and identifies the code C335 (field) in which the annotation C333 is indicated in the source code as code to be updated (in other words, an update location). Then, the update unit 112 of the information processing device 100 adds code that indirectly indicates the generation of an object indicated by the code C335, based on the result of identifying the code C335 to be updated. Specifically, the information processing device 100 adds an abstract class C334 corresponding to the code to be updated to the project C331, and then adds code for invoking a generation process of a target object to the abstract class C334. The information processing device 100 also adds code for invoking the above process of the generated abstract class C334 to the code C335 to be updated. At this time, the information processing device 100 specifies the object to be generated based on, for example, an annotation added to a class that the framework treats as a component to be managed. For example, the object set in the field C335 is an object of class A or class B. In the example shown in FIG. 2(a), an annotation C339 indicated by the keyword "@Component" that indicates that it is a component to be managed is added to the class B. On the other hand, an annotation that indicates that it is a component to be managed is not added to the class A. Therefore, the information processing device 100 recognizes that the object set in the field C335 is an object of class B, and adds a code that indirectly indicates the generation of an object of class B.

[0018] Moreover, the information processing device 100 generates a project C332 separate from the project C331 to be analyzed, and adds to the project C332 a class C336 that inherits the abstract class C334, and an execution code C337 that is a starting point for generating a call graph. Specifically, the information processing device 100 adds to the class C336 a code for a process called by the code defined in the abstract class C334, and adds to the code a code that directly indicates the generation of a target object (for example, a code for creating a new object). Furthermore, the information processing device 100 specifies, in the execution code C337, a code for generating an object of the class C336, and for the process of the object, a code for calling the process of the abstract class C334 that was added in association with the object indicated by the code C335 in the source code to be updated. In addition, in this disclosure, "inheritance" corresponds to inheritance defined as one of the concepts constituting object orientation, and means that an object inherits the characteristics of another object. In other words, in this disclosure, inheritance means that common parts related to class definitions are consolidated into a different class. In addition, as long as it is possible to generate an execution code (a code equivalent to the source code C337) that satisfies the above-mentioned requirements, the method is not particularly limited. For example, it is possible to generate an execution code that satisfies the above-mentioned requirements by using the method disclosed in the reference document shown below. ·Reference: Jens Dietrich, Francois Gauthier, and Padmanabhan Krishnan. 2018. Driver Generation for Java EE Web Applications. In Australasian Software Engineering Conference (ASWEC). IEEE, 121-25. As another example, it is possible to generate execution code that satisfies the above-mentioned requirements by using annotations added by the framework to the source code to be analyzed. The method of generating execution code using annotations will be described in detail later as a modified example of this embodiment. In FIG. 2(a), annotation C333 indicated by the keyword "@Autowired", which means that a dependency relationship between objects is configured at run time, corresponds to an example of a "first annotation" suggesting the generation of an object. That is, the source code to which annotation C333 is added, i.e., the source code to be updated, corresponds to an example of a "first source code". The object whose generation is suggested by annotation C333 corresponds to an example of a "first object", and the field corresponding to the first object in the first source code (the field corresponding to code C335) corresponds to an example of a "first field".

[0019] Note that the keyword added as the annotation C333 may differ depending on the framework to be applied. Therefore, the information processing device 100 may appropriately change the keyword extracted as the annotation C333 depending on the framework to be applied. Also, as long as the information processing device 100 can identify the framework to be applied, the method is not particularly limited. As a specific example, the information processing device 100 may recognize the framework to be applied in response to an instruction from a user, and change the keyword to be extracted as the annotation C333 depending on the framework. Also, as another example, the information processing device 100 may recognize the framework to be applied by analyzing information included in the source code specified as the analysis target, a configuration file linked to the source code, or the like.

[0020] FIG. 2(b) shows an example of a call graph showing the call relationship between objects when a program of the source code before the update is executed. FIG. 2(c) shows an example of a call graph generated by pointer analysis (static analysis) of the updated source code shown in FIG. 2(a). As can be seen by comparing FIG. 2(b) and FIG. 2(c), although the call graphs are different as a whole, the call graph shown in FIG. 2(c) includes a call graph substantially similar to the call graph shown in FIG. 2(b) as a partial call graph C338. That is, the call graph shown in FIG. 2(c) includes a call graph C338 substantially similar to the call graph originally assumed, and a call graph generated based on the code added for the analysis. Under such a premise, for example, by extracting the call graph of the source code to be analyzed from the series of call graphs shown in FIG. 2(c) using the package name or the like as an extraction condition, it becomes possible to generate a call graph (i.e., the call graph C338) that is in accordance with the actual situation even under the situation where pointer analysis is used. In the following, the information processing device 100 according to this embodiment will be described in more detail.

[0021] (Hardware configuration) An example of a hardware configuration of the information processing device according to the present embodiment will be described with reference to FIG. 3. As shown in FIG. 1, the information processing device 100 according to the present embodiment includes a central processing unit (CPU) 910, a read only memory (ROM) 920, and a random access memory (RAM) 930. The information processing device 100 also includes an auxiliary storage device 940 and a network I / F 970. The information processing device 100 may also include at least one of an output device 950 and an input device 960. The CPU 910, the ROM 920, the RAM 930, the auxiliary storage device 940, the output device 950, the input device 960, and the network I / F 970 are connected to each other via a bus 980.

[0022] The CPU 910 is a central processing unit that controls various operations of the information processing device 100. For example, the CPU 910 may control the operation of the entire information processing device 100. The ROM 920 stores a control program, a boot program, and the like that can be executed by the CPU 910. The RAM 930 is the main storage memory of the CPU 910, and is used as a work area or a temporary storage area for expanding various programs.

[0023] The auxiliary storage device 940 stores various data and various programs. The auxiliary storage device 940 is realized by a storage device capable of temporarily or persistently storing various data, such as a non-volatile memory represented by an HDD (Hard Disk Drive) or an SSD (Solid State Drive).

[0024] The output device 950 is a device that outputs various types of information, and is used to present various types of information to a user. For example, the output device 950 may be realized by a display device such as a display. In this case, the output device 950 presents information to a user by displaying various types of display information. As another example, the output device 950 may be realized by an audio output device that outputs sounds such as voice and electronic sounds. In this case, the output device 950 presents information to a user by outputting sounds such as voice and telegrams. In addition, a device applied as the output device 950 may be appropriately changed depending on a medium used to present information to a user.

[0025] The input device 960 is used to receive various instructions from the user. In this embodiment, the input device 960 includes input devices such as a mouse, a keyboard, and a touch panel. As another example, the input device 960 may include a sound collection device such as a microphone, and collect the voice uttered by the user. In this case, various analysis processes such as acoustic analysis and natural language processing are performed on the collected voice, and the content indicated by the voice is recognized as an instruction from the user. In addition, the device applied as the input device 960 may be appropriately changed depending on the method of recognizing the instruction from the user. In addition, multiple types of devices may be applied as the input device 960.

[0026] The network I / F 970 is used for communication with an external device via a network. The device used as the network I / F 970 may be changed as appropriate depending on the type of communication path and the communication method used.

[0027] The CPU 910 expands a program stored in the ROM 220 or the auxiliary storage device 940 into the RAM 930 and executes this program, thereby realizing the functional configuration of the information processing device described later with reference to Figure 4 and the processing of the information processing device described later with reference to Figure 5.

[0028] (Functional configuration) An example of a functional configuration of the information processing device 100 according to this embodiment will be described with reference to Fig. 4. As shown in Fig. 4, the information processing device 100 according to this embodiment includes a control unit 110 and a call graph generation unit 120.

[0029] The control unit 110 receives an input of a series of source codes D210 to be analyzed, performs the update described with reference to Fig. 2 on the source codes D210, and outputs the updated source codes D220 to a predetermined output destination.

[0030] The analysis unit 111 performs a predetermined analysis on a series of source codes D210 to be analyzed, thereby identifying source codes to be processed for generating a call graph and code in the source codes to be processed, from the series of source codes D210. For example, in the case of this embodiment, the analysis unit 111 performs a predetermined analysis on the series of source codes D210 to be analyzed, thereby identifying source codes to be updated and code in the source codes to be updated. As a specific example, as described with reference to FIG. 2(a), the analysis unit 111 may extract source code to which a specific annotation has been added as source code to be updated, and identify the code in which the annotation is indicated in the source code as the code to be updated. As another example, the analysis unit 111 may extract source code to be updated based on a setting file that specifies the objects to be generated for each source code associated with the series of source code D210 to be analyzed and the fields in which the objects are held. In this case, the analysis unit 111 may specify code to be updated in the extracted source code based on the definitions in the setting file of the objects to be generated and the fields in which the objects are held. Note that an example of a method for extracting source code to be updated and specifying code to be updated in the source code based on the setting file will be described in detail later with reference to FIG. 7. Furthermore, when there is other source code that has a dependency relationship with the series of source codes D210 to be analyzed but is not included in the series of source codes D210, the analysis unit 111 may also include the other source code in the analysis target. As a specific example, when a series of source codes to be analyzed is specified by a management unit used for managing source codes such as a project, the analysis unit 111 may identify the dependency relationship between the management units by using a configuration file or the like. Then, when another management unit that has a dependency relationship with the management unit specified as the analysis target is not included in the analysis target, the analysis unit 111 may also include the other management unit in the analysis target.

[0031] The update unit 112 executes processes related to the generation and update of source code for generating a call graph for a series of source code D210, based on the results of identification of the target source code and the code in the source code by the analysis unit 111. For example, based on the result of the analysis unit 111 identifying the first source code to be updated and the code in the first source code, the update unit 112 performs an update to add a code indirectly indicating the generation of an object to the first source code, as described with reference to FIG. 2(a). The update unit 112 also generates a second source code, which is a source code different from the first source code to be updated, in association with the code indirectly indicating the generation of the object, and in which a code directly indicating the generation of the object is defined. Then, based on the result of the update of the first source code to be analyzed and the result of the generation of the second source code, the update unit 112 generates an execution code (a code in which a so-called Main class is defined) that serves as a starting point for generating a call graph with at least the first source code as a target. Specifically, the update unit 112 generates the execution code so that the process defined in the updated first source code is called by calling a process defined in the second source code, as described with reference to FIG. 2(a). At this time, the update section 112 may manage the second source code and the execution code in association with a project different from a project (management unit) for managing the first source code to be updated. Then, the update unit 112 outputs the series of source codes to be analyzed including the updated first source code, and the generated second source code and execution code to a predetermined output destination as a series of source codes D220 for generating a call graph. For example, in the example shown in Fig. 4, the update unit 112 outputs the series of source codes D220 for generating a call graph to the call graph generation unit 120 described later.

[0032] The call graph generating unit 120 generates a call graph by static analysis such as so-called pointer analysis, targeting a series of source codes D220 for generating a call graph output from the control unit 110. Note that as long as it is possible to generate a so-called call graph by analyzing the source code, the method (e.g., a method of analyzing the source code) is not particularly limited. That is, a known logic may be applied to the generation of the call graph. Therefore, for example, a known tool that analyzes a series of input source codes to generate a call graph may be applied as the call graph generating unit 120. In this manner, the call graph generating unit 120 generates a call graph D230 using the series of source codes D220 as an input, and outputs the generated call graph D230 to a predetermined output destination.

[0033] It should be noted that the configuration shown in FIG. 4 is merely an example and does not necessarily limit the functional configuration of the information processing device 100 according to the present embodiment. For example, the series of components shown in FIG. 4 may be realized by cooperation of a plurality of devices. As a specific example, a component corresponding to the call graph generating unit 120 may be realized by another device other than the information processing device 100. In this case, the information processing device 100 including the control unit 110 may transmit a series of source codes D220 for generating a call graph to the other device connected via a network. As another example, the control unit 110 may output a series of source codes D220 for generating a call graph to a predetermined storage device (e.g., a server for data management, etc.). In this case, the other device including the call graph generating unit 120 may acquire a series of source codes to be used for generating a call graph from the storage device. As another example, the processing load of at least some of the components in the series of components shown in FIG. 4 may be distributed to a plurality of devices. Furthermore, at least some of the components of the series of components shown in FIG. 4 may be realized by a so-called network service such as a cloud service.

[0034] (process) An example of processing by the information processing device 100 according to this embodiment will be described with reference to FIG. In S110, the control unit 110 receives an input of a series of source codes D210 to be analyzed. In addition, at this time, the control unit 110 may check whether there is other source code having a dependency relationship with the series of source codes D210 to be analyzed, and may include the other source codes in the analysis target.

[0035] In S120, the analysis unit 111 performs a predetermined analysis process on the series of source codes D210 received as an analysis target in S110, thereby identifying source codes to be updated and an update location in the source codes (i.e., code to be updated). As a specific example, the analysis unit 111 may extract source codes to which a predetermined annotation C333 is added as a first source code to be updated, and identify the code in the first source code where the annotation C333 is indicated as the update location.

[0036] In S130, the update unit 112 updates the first source code by adding a code indirectly indicating the generation of an object corresponding to the code indicated in the update portion to the first source code based on the result of identifying the first source code to be updated and the update portion in S120. The update unit 112 also generates a second source code, which is a different source code from the first source code to be updated, in association with the code indirectly indicating the generation of the object, and in which a code directly indicating the generation of the object is defined. Then, the update unit 112 generates an execution code that is a starting point for generating a call graph with at least the first source code as a target, based on the update result of the first source code to be analyzed and the generation result of the second source code. The update unit 112 then outputs a series of source codes to be analyzed including the updated first source code, and the generated second source code and execution code to a predetermined output destination as a series of source codes for generating a call graph. The series of source codes output from the update unit 112 in the manner described above is used by the call graph generation unit 120 to generate a call graph, for example.

[0037] (Modification) As a modification of this embodiment, an example of a method in which the information processing device 100 uses annotations added by a framework to a source code to be analyzed when generating an execution code to identify a process to be called in the execution code will be described. For example, Fig. 19 is an explanatory diagram for explaining an outline of the functions of an information processing device according to this modification. Note that in the example shown in Fig. 19, a portion of the source code used in the description is illustrated as the target, and other source codes are omitted from the illustration.

[0038] Source code C351 shown in Fig. 19(a) is an example of source code to be analyzed. In source code C351, similar to source code C111 shown in Fig. 1(a), a field C354 of an object of class B and code C358 that calls a process (method) of the object held in field C354 are defined in the code of class X. Moreover, the annotation C355 indicated by "@Controller" is added to the above class X. This annotation C355 is an annotation that is added to a class that is the starting point of application execution, and can be added to, for example, a class that is called first in response to an HTTP request. Moreover, the above code C358 is added with an annotation C356 indicated by the keyword "@RequestMapping". This annotation C356 is defined in association with the annotation C355, and is added to a method that receives and processes an HTTP request, and the "method" attribute specifies which HTTP method the request is to be processed. Similarly to the annotation C356, other annotations that can specify which HTTP method the request is to be processed include annotations indicated by keywords such as "@GetMapping", "@PostMapping", "@PutMapping", "@DeleteMapping", and "@PatchMapping". In this modified example, these annotations are also treated in the same way as the annotation C356. Note that the @Controller annotation includes the @Component annotation. In other words, class X with the @Controller annotation will also be managed as a component.

[0039] 19(b) shows an example of a result of updating the source code to be analyzed by the information processing device 100 according to this modification. Specifically, source code C352 shows an example of the source code to be analyzed after being updated by modifying the source code by the information processing device 100. Source code C353 is an execution code that calls a process defined in the updated source code C352.

[0040] In source code C352, similar to the example described with reference to Figures 1 and 2, field C354 is updated by adding code that indirectly indicates the generation of an object of class B. Note that the method of updating source code C351 to source code C352 is similar to the example described with reference to Figures 1 and 2, so detailed description thereof will be omitted.

[0041] Furthermore, when generating the execution code C353, the information processing device 100 according to this modification specifies the process to be called by the execution code C353 based on the annotations C355 and C356. Specifically, the information processing device 100 identifies a class that is to be the target of the process invocation based on the annotation C355 added to the source code C351 to be analyzed. In the example shown in Fig. 19, the information processing device 100 identifies class X as the target. Next, the information processing device 100 identifies a process to be called by the execution code from among a series of processes of the class identified as a target, based on the annotation C356 added to the source code C351 to be analyzed. For example, in the example shown in Fig. 19, the annotation C356 is added to the process indicated by the code C358 in the class X. Therefore, the information processing device 100 generates the execution code C353 so that the process indicated by the code C358 is called as the process of the object of the class X.

[0042] As a modification of this embodiment, an example of a method in which the information processing device 100 uses annotations added by a framework to a source code to be analyzed when generating the execution code to identify a process to be called in the execution code has been described above.

[0043] (Action and effect) As described above, the information processing device 100 according to the present embodiment identifies a first source code to be updated and a code to be updated in the first source code from a series of source codes to be analyzed. For example, the information processing device 100 may extract a source code to which a predetermined annotation is added as the first source code to be updated, and identify the code to which the annotation is added as an update location. Then, the information processing device 100 updates the first source code by adding a code indirectly indicating the generation of an object corresponding to the code (for example, a field) indicated in the update location identified in the first source code to be updated. In addition, the information processing device 100 generates a second source code, which is associated with the code indirectly indicating the generation of the object as another source code different from the first source code to be updated, and in which a code directly indicating the generation of the object is defined. Then, the information processing device 100 generates an execution code that is a starting point for generating a call graph for at least the first source code, based on the update result of the first source code to be analyzed and the generation result of the second source code. Then, the information processing device 100 outputs the series of source codes to be analyzed, including the updated first source code, and the generated second source code and execution code, to a predetermined output destination as a series of source codes for generating a call graph. By using the series of source codes generated in the above manner, it becomes possible to generate a call graph that is more in line with reality, even when static analysis such as pointer analysis is used to generate the call graph, as described with reference to FIG.

[0044] <Second embodiment> A second embodiment of the present disclosure will be described. In the above-mentioned embodiment, an example of a mechanism that enables a call graph that is more in line with the actual situation to be generated even when static analysis such as pointer analysis is used to generate a call graph by updating a part of source code to be analyzed by adding code related to object generation to the source code to be analyzed. In contrast, in this embodiment, an example of a mechanism that enables a call graph that is more in line with the actual situation to be generated even when static analysis such as pointer analysis is used to generate a call graph by adding other source code that calls the processing of the source code to be analyzed without updating the source code to be analyzed. Note that in this embodiment, the description will be given focusing on parts that are particularly different from the first embodiment described above, and detailed description of parts that are substantially the same as the first embodiment will be omitted.

[0045] First, referring to FIG. 6, an example of source code to be analyzed in this embodiment and an example of a call graph showing the call relationship between objects for the source code will be described. Specifically, in the source code C611 shown in FIG. 6(a), a field C612 of an object of class B and a code C613 for calling a process (method) of an object held in the field C612 are defined in the code of class X. Also, in the source code C611, a code C614 for setting an object designated by a caller in the field C612 is defined as a code for referencing the field C612. FIG. 6(b) shows an example of a call graph showing the call relationship between objects when a program of the source code as exemplified in FIG. 6(a) is executed under such a premise. Also, as in the example described with reference to FIG. 1, in the pointer analysis, the generation of an object for the field C612 is not explicitly defined, so the field C612 is treated as Null. Therefore, when attempting to generate a call graph for source code C611 using pointer analysis (static analysis), a call graph that is not based on reality may be generated, as shown in Figure 6(c), which is based on the assumption that an object of class B has not been generated.

[0046] In consideration of the above situation, the information processing device 100 according to the present embodiment enables the generation of a call graph more in line with the actual situation by adding other source code that calls the processing of the source code to be analyzed without updating the source code. For example, Fig. 7 and Fig. 8 are explanatory diagrams for explaining an overview of the functions of the information processing device 100 according to the present embodiment.

[0047] First, an example of a method in which the information processing device 100 according to the present embodiment identifies source code to be updated and code to be updated in the source code from a series of source codes specified as analysis targets will be described with reference to Fig. 7. Methods for identifying source code and code to be updated include a method of using annotations added to the source code and a method of using a configuration file associated with the series of source codes specified as analysis targets.

[0048] For example, Fig. 7(a) is a diagram showing an example of a method for identifying source code and code to be subjected to processing related to adding source code for generating a call graph, using annotations added in the source code. Depending on the framework, annotations may be added to the code of a target class in order to control instances (objects) generated with the execution of code defined in the source code. For example, in the example shown in FIG. 7(a), annotation C615 indicated by the keyword "@Component" is added to code related to the provision of class B, and indicates that an object (instance) of class B generated by execution of the code is under the management of the framework. In addition, other annotations including annotation C615 indicated by the keyword "@Component" may be added, and such annotations may be indicated by, for example, keywords "@Controller", "@Service", etc. For example, annotation C616 shown in FIG. 7(a) is added to code related to the provision of class X, and indicates that an object of class X generated by execution of the code is under the management of the framework.

[0049] In the example shown in Figure 7 (a), the information processing device 100 of this embodiment uses the annotations exemplified above to identify source code including the code to which the annotations are attached as the target of processing related to adding source code for generating a call graph. Furthermore, the information processing device 100 according to this embodiment identifies code to be processed for adding source code for generating a call graph, based on annotations that indicate that dependencies between objects are configured at run time, as in the example described in the first embodiment. For example, in the example shown in Fig. 7(a), the information processing device 100 identifies code C614 to which an annotation indicated by the keyword "@Autowired" is added, as code to be processed for adding source code for generating a call graph.

[0050] Fig. 7(b) is a diagram showing an example of a method for identifying source code and code to be subjected to processing related to adding source code for generating a call graph, using a configuration file associated with a series of source codes specified as analysis targets. The configuration file shown in Fig. 7(b) shows an example of a configuration file used by a framework to manage objects (instances) generated with the execution of code defined in the source code. The configuration file includes specifications for classes in which objects to be managed are generated and specifications for fields in which the objects are set. As a specific example, in the configuration file C621 shown in Fig. 7(b), the class in which an object to be managed is generated is specified by a tag indicated by the keyword "bean". As a more specific example, for tag C622, the class B in which an object is to be generated is specified as attribute information indicated by the keyword "class". As another example, for tag C623, the class X in which an object is to be generated is specified as attribute information indicated by the keyword "class". That is, the example shown in Fig. 7(b) indicates that objects of class B and class X are under the management of the framework. The information processing device 100 of this embodiment uses the provisions of the configuration file as exemplified above to identify the source code of a class corresponding to an object managed by the framework as the target of processing related to adding source code for generating a call graph.

[0051] In addition, in the tag related to the above-mentioned class definition indicated by the keyword "bean", a setter method for setting an object (instance) in the target field is specified by the tag indicated by the keyword "property". For example, in the tag C623 related to the class X definition, a setter method (setB) is specified for the name attribute "b" of the tag C624 indicated by the keyword "property". In addition, in the tags related to the definition of the above fields, a tag indicated by the keyword "ref" specifies which class of object is to be set for the target field. For example, in the tag C624 related to the definition of field b, a tag C625 indicating a class corresponding to the object indicated by the keyword "ref" to be set is defined. Furthermore, in the tag C625, identification information for identifying the target class is specified as attribute information indicated by the keyword "bean". For example, in the example shown in FIG. 7(b), identification information assigned to class B indicated by tag C622 is specified as the attribute information. That is, the configuration file C621 shown in FIG. 7(b) indicates that an object of class B is to be set for field b defined for class X. The information processing device 100 of this embodiment uses the field specifications in the configuration file exemplified above to identify the code specified by the specifications as the code to be subjected to the process of adding source code for generating a call graph.

[0052] Next, with reference to FIG. 8, an example of other source code (source code for generating a call graph) added by the information processing device 100 according to the present embodiment to generate a call graph of a series of source codes to be analyzed will be described. In the example shown in FIG. 8, for convenience, a part of source code that is particularly important is extracted and illustrated from a series of source codes included in a project (hereinafter also referred to as project prj1) designated as an analysis target. Also, in the example shown in FIG. 8, as a state of the project prj1 designated as an analysis target, a state after the source code of abstract class C631 is added to the project prj1 as other source code for generating a call graph of the target source code C611 is shown. In the abstract class C631, a code is prescribed that returns an object (instance) corresponding to a field identified as a target based on the example described with reference to FIG. 7 in response to a call. For example, in the code C632, a code is prescribed that calls a process of class C641 that inherits abstract class C631 as a code that returns an object of class X set in field x in response to a call. That is, the actual processing of the code C632 is defined as the processing of the class C641. The processing of the class C641 will be described in detail later.

[0053] Furthermore, the information processing device 100 according to this embodiment generates another project (hereinafter also referred to as project main) that is used to manage other source code for generating a call graph of the source code to be analyzed, separately from the project prj1 to be analyzed. Then, the information processing device 100 adds, to the project main, a class C641 that inherits the abstract class C631, and an execution code C651 that is the starting point for generating the call graph.

[0054] Specifically, the information processing device 100 prescribes, for the class C641, a field for holding an object returned by the code defined in the abstract class C631 as a so-called static field that can be used without generating an instance. For example, the field C643 is a field for holding an object of class X that is returned by calling the code C632 defined in the abstract class C631. The field defined in the class C641 corresponds to an example of a "second field". Furthermore, the information processing device 100 adds a code in which the generation of an object corresponding to the above field is directly prescribe. In the above field, an object generated by a process defined as the code is set. For example, the code C642 prescribes a process for generating an object of class X. In addition, in the field C643, an object generated by a process defined as the code C642 is set. Furthermore, the information processing device 100 adds a code in which a substantial process for returning an object held in the above field is prescribes as a code called from the code defined in the abstract class C631. For example, code C644 is called from code C632 defined in abstract class C631, and defines a process for returning an object of class X held in field C643. The source code of this class C641 corresponds to an example of the "second source code" in this embodiment.

[0055] Furthermore, the information processing device 100 prescribes a code for acquiring an object held in a field C643 of the class C641 by calling an initialization process of the class C641 for the execution code C651 and then calling the code C632 of the abstract class C631. For example, in the case of the example shown in FIG. 8, an object of the class X is acquired by the process indicated by the code. Then, the information processing device 100 prescribes a code C652 for invoking the process of the object acquired by the above code, that is, the process for which a call graph is to be generated, for the execution code C651. Note that the method of identifying the process for which a call graph is to be generated is the same as the example described with reference to FIG. 1, and therefore a detailed description thereof will be omitted.

[0056] Then, the information processing device 100 generates a call graph based on a series of source codes (for example, the series of source codes illustrated in FIG. 8) including the first source code to be analyzed and the generated second source code and execution code.

[0057] For example, FIG. 9 is a diagram for explaining an example of a call graph generated based on a series of source codes illustrated in FIG. 6 and FIG. 8. Specifically, FIG. 9(a) shows an example of a call graph showing the call relationship between objects when a program of a source code to be analyzed is executed. Also, FIG. 9(b) shows an example of a call graph generated based on a series of source codes illustrated in FIG. 6 and FIG. 8. As can be seen by comparing FIG. 9(a) and FIG. 9(b), although the call graphs are different as a whole, the call graph illustrated in FIG. 9(b) includes a call graph substantially similar to the call graph illustrated in FIG. 9(a) as a partial call graph C661. That is, the call graph illustrated in FIG. 9(b) includes a call graph C661 substantially similar to the call graph originally assumed, and a call graph generated based on a code added for analysis. Under such a premise, in order to obtain a call graph substantially equivalent to the original call graph by removing the unnecessary parts, for example, the call graph of the source code to be analyzed may be extracted from the series of call graphs illustrated in FIG. 9(b) using a package name or the like as an extraction condition. In this manner, also in this embodiment, even in a situation where pointer analysis is used, it is possible to generate a call graph that matches the actual situation (that is, the call graph C661).

[0058] As described above, the information processing device 100 according to this embodiment makes it possible to generate a call graph that is more in line with reality, even when a static analysis such as pointer analysis is used to generate the call graph, without updating the source code to be analyzed.

[0059] (Modification) Next, a modified example of the second embodiment of the present disclosure will be described below. In this modified example, an example will be described in which a series of source codes to be analyzed includes source codes having dependencies with source codes belonging to other projects.

[0060] For example, Fig. 10 is a diagram showing an example of source code to be analyzed in this modified example. For convenience, the example shown in Fig. 10 shows an excerpt of a part of source code that is particularly important among a series of source codes included in a project specified as an analysis target. Specifically, in the example shown in FIG. 10, source code C711 that specifies classes A and X is included in project prj1, and source code C712 that specifies class B that inherits class A is included in project prj2. In addition, processing of an object of class B that inherits class A is called as processing of an object of class X. In other words, in the example shown in FIG. 10, in processing within class X, an object of class B that inherits class A is applied as an object of class A. That is, in the example shown in FIG. 10, source code belonging to project prj2 (e.g., source code of class B) depends on source code belonging to project prj1 (e.g., source code of class A). In such a case, it is preferable to add source code for generating a call graph for each management unit (e.g., project) that manages the source code to be analyzed. In this modified example, the source code C711 corresponds to an example of a "first source code", and the source code C712 corresponds to an example of a "third source code".

[0061] Fig. 11 is a diagram showing an example of another source code (a source code for generating a call graph) that the information processing device 100 according to this modification adds in order to generate a call graph of a series of source codes to be analyzed. Fig. 11 shows an example of another source code for generating a call graph of a series of source codes, which is added by the information processing device 100 to the series of source codes to be analyzed shown in Fig. 10 as an example.

[0062] Specifically, the information processing device 100 adds the source code of the abstract class C721 to the project prj1 to which the source code C711 belongs, as another source code for generating a call graph of the source code C711. The abstract class C721 corresponds to the abstract class C631 in the example shown in Fig. 8, which targets the source code C711. The abstract class C721 defines a code C722 that returns, in response to a call, an object corresponding to a field identified as a target based on the example described with reference to Fig. 7 (in this case, an object corresponding to class B that inherits class A). Similarly, the information processing device 100 adds the source code of the abstract class C731 to the project prj2 to which the source code C712 belongs, as another source code for generating a call graph of the source code C712. The abstract class C731 corresponds to the abstract class C631 in the example shown in Fig. 8, which targets the source code C712. The abstract class C731 defines a code C732 that returns, in response to a call, an object corresponding to the field identified as the target based on the example described with reference to Fig. 7 (an object corresponding to class B).

[0063] Furthermore, the information processing device 100 according to this modification generates another project (project main) used for managing other source code for generating a call graph of the source code to be analyzed, separately from the projects prj1 and prj2 to be analyzed. Then, the information processing device 100 adds to the project main a class C741 that inherits the abstract class C721, a class C751 that inherits the abstract class C731, and an execution code C761 (to be described later with reference to FIG. 12) that is the starting point for generating the call graph.

[0064] The information processing device 100 defines, for the class C741, a field for holding an object returned by the code defined in the abstract class C721 as a so-called static field that can be used without generating an instance. For example, the field C743 is a field for holding an object of class B that inherits class A, which is returned by calling the code C722 defined in the abstract class C721. 10, in the processing of class X in source code C711, an object of class B that inherits class A is applied as an object of class A. Therefore, code for setting an object in field C743 is defined so that the generation of an object held in field C743 is executed as processing of class C751, which will be described later. Specifically, code for calling code C732 defined in abstract class C731 is defined as code for setting an object in field C743. As a result, code C754, which will be described later, is called via code C732, and the object of class B returned as a result is set in field C743. Furthermore, the information processing apparatus 100 adds code C744, in which substantial processing for returning an object held in field C743 is defined, as code to be called from code C722 defined in abstract class C721. In this modified example, the source code of class C741 corresponds to an example of a "second source code." Also, field C743 defined in class C741 corresponds to an example of a "second field" in this modified example, and an object held in field C743 corresponds to an example of a "first object" in this modified example.

[0065] Furthermore, the information processing device 100 defines, for the class C751, a field for holding an object returned by the code defined in the abstract class C731 as a so-called static field that can be used without generating an instance. For example, the field C753 is a field for holding an object of class B that is returned by calling the code C732 defined in the abstract class C731. 10, there is no other class that depends on class B. Therefore, information processing device 100 adds code C752 that directly specifies the generation of an object (object of class B) corresponding to field C753. An object generated by the process specified as code C752 is set in field C753. Furthermore, the information processing apparatus 100 adds code C754, in which substantial processing for returning an object held in a field is defined, as code to be called from code C732 defined in the abstract class C731. In this modification, the source code of class C751 corresponds to an example of a "fourth source code." Also, field C753 defined in class C741 corresponds to an example of a "third field" in this modification, and an object held in the field C753 corresponds to an example of a "second object" in this modification.

[0066] Furthermore, the information processing apparatus 100 adds, to the project "main", an execution code C761 that serves as a starting point for generating a call graph. For example, Fig. 12 is a diagram showing an example of the execution code according to this modified example. In the example shown in Fig. 12, the information processing device 100 prescribes, for the execution code C761, a code for invoking the initialization process of each of classes C741 and C751, and then invoking the code of the class C741, thereby acquiring an object of class X held in the field of the class C741. Then, for the execution code C761, the information processing device 100 prescribes a code for invoking the process of the object of class X acquired by the above code, that is, the process for which a call graph is to be generated. Note that the method of identifying the process for which a call graph is to be generated is the same as the example described with reference to Fig. 1, and therefore a detailed description thereof will be omitted.

[0067] Then, the update unit 112 outputs a series of source codes including the first source code to be analyzed and the generated second source code and execution code (for example, the series of source codes illustrated in FIG. 8) to a predetermined output destination as a series of source codes for generating a call graph.

[0068] Then, the information processing device 100 generates a call graph based on a series of source codes (for example, a series of source codes illustrated in Figures 11 and 12) including the first source code and third source code to be analyzed, and the generated second source code, fourth source code, and execution code.

[0069] For example, FIG. 13 is a diagram for explaining an example of a call graph generated based on a series of source codes illustrated in FIG. 10, FIG. 11, and FIG. 12. Specifically, FIG. 13(a) shows an example of a call graph showing a call relationship between objects when a program of a source code to be analyzed is executed. Also, FIG. 13(b) shows an example of a call graph generated based on a series of source codes illustrated in FIG. 10, FIG. 11, and FIG. 12. As can be seen by comparing FIG. 13(a) and FIG. 13(b), although the call graphs are different as a whole, the call graph illustrated in FIG. 13(b) includes a call graph substantially similar to the call graph illustrated in FIG. 13(a) as a partial call graph C771. That is, the call graph illustrated in FIG. 13(b) includes a call graph C771 substantially similar to the call graph originally expected, and a call graph generated based on a code added for analysis. Under these assumptions, in order to obtain a call graph that is substantially equivalent to the original call graph by removing unnecessary parts, for example, the call graph of the source code to be analyzed may be extracted from the series of call graphs shown in Fig. 13(b) by using the package name or the like as an extraction condition. In this way, even in the present embodiment, it is possible to generate a call graph that matches the actual situation (i.e., the call graph C771) even in a situation where pointer analysis is used.

[0070] As described above, the information processing device 100 according to this modified example makes it possible to generate a call graph that is more in line with reality even when the series of source codes to be analyzed includes source codes that have dependencies on source codes belonging to other projects.

[0071] <Third embodiment> A third embodiment of the present disclosure will be described below. In this embodiment, as an embodiment that further expands each of the above-mentioned embodiments, an example of a mechanism for generating a call graph of a source code to be analyzed will be described, taking into consideration a case where the source code is specified based on a design concept (design pattern) called a Singleton. Note that in this embodiment, the description will focus on parts that are particularly different from the first and second embodiments described above, and detailed descriptions of parts that are substantially similar to the first and second embodiments will be omitted.

[0072] First, in order to more clearly explain the features of this embodiment, an overview of the difference between a case where a singleton is not applied and a case where a singleton is applied will be described with reference to FIGS. 14A and 14B.

[0073] For example, FIG. 14A is a diagram showing an example of a case where singletons are not applied. Specifically, FIG. 14A(a) is a diagram showing an example of source code to be analyzed. In the example shown in FIG. 14A(a), as a premise, an object of Dog class is set in the pet field of an object of House class (hereinafter also referred to as house object) for each of objects x and y. Under such circumstances, for object x, the object set in the pet field of the house object is replaced with an object of Cat class (i.e., the object of Cat class is newed and assigned). For reference, FIG. 15 shows an example of source code of a series of objects defined by the source code shown in FIG. 14A and FIG. 14B described later. Fig. 14A(b) shows an example of the result of applying pointer analysis to the source code shown in Fig. 14A(a) in a situation where singletons are not applied. When singletons are not applied, house objects are generated separately for objects x and y, so that different house objects are called from objects x and y, as shown in Fig. 14A(b). That is, for object x, the generation process of a Cat class object is called from the house object, and for object y, the generation process of a Dog class object is called from the house object. Fig. 14A(c) shows an example of a call graph output as a result of the pointer analysis described with reference to Fig. 14A(b). That is, from the main method of the Main class, the cry method of the Cat class, which is called as processing of object x, and the cry method of the Dog class, which is called as processing of object y, are output to the call graph.

[0074] FIG. 14B is a diagram showing an example in which a singleton is applied. Specifically, Fig. 14B(a) is a diagram showing an example of source code to be analyzed. The example shown in Fig. 14B(a) is similar to the example shown in Fig. 14A(a) in terms of code description, but differs from the example shown in Fig. 14A(a) in whether a singleton is applied or not. Fig. 14B(b) shows an example of the result of applying pointer analysis to the source code shown in Fig. 14A(a) when a singleton is applied. When a singleton is applied, a common house object is applied to each of objects x and y, so that a common house object is called from each of objects x and y, as shown in Fig. 14B(b). Fig. 14B(c) shows an example of a call graph output as a result of the pointer analysis described with reference to Fig. 14B(b). That is, the cry method of the Cat class, which is commonly called as processing for objects x and y from the main method of the Main class, is output to the call graph, but the cry method of the Dog class is not output to the call graph. In the following description, for convenience, an object to which the singleton is applied is also referred to as a singleton object. That is, in the example shown in Fig. 14B, the house object is a singleton object. In contrast, in the example shown in Fig. 14A, the house object is not a singleton object.

[0075] 14A and 14B, even when a common source code is applied, the behavior of the program differs depending on whether a singleton is applied, and as a result, the output call graph also differs. In view of this situation, in this embodiment, an example of updating the source code to be analyzed so that a call graph that is more in line with the actual situation is generated by taking into account whether a singleton is applied to the source code.

[0076] First, an example of a mechanism by which the information processing device 100 according to the present embodiment determines whether a singleton is applied to source code to be analyzed will be described. For example, some frameworks allow the scope of a target program to be specified by an annotation added to the source code, a configuration file associated with the source code, or the like. In such a case, for example, it may be possible to set whether or not a singleton is applied as a setting for the scope. Therefore, for example, the information processing device 100 may determine whether or not a singleton is applied to the target source code by using the mechanism of such a framework.

[0077] For example, Fig. 16 is a diagram showing an example of a mechanism for determining whether a singleton is applied to source code based on an annotation added to the source code by a framework. In the example shown in Fig. 16, whether a singleton is applied is shown according to whether an annotation indicated by the keyword "@Scope", which means the specification of the scope of the program realized by the target source code, is added or not, and according to the parameters specified in the annotation. Specifically, as shown in FIG. 16(a) and FIG. 16(b), the annotation "@Scope" can specify an attribute value as a parameter, and the scope of the target source code is determined according to the attribute value specified as the parameter. In addition, when "singleton" meaning the application of a singleton is specified as an attribute value for this annotation "@Scope", it means that a singleton is applied to the target source code. That is, in the example shown in FIG. 16(a), the annotation "@Scope" means that a singleton is not applied. Also, in the example shown in FIG. 16(b), the annotation "@Scope" means that a singleton is applied. Therefore, the information processing device 100 may determine whether or not a singleton is applied to the target source code based on the attribute value specified for the annotation added to the target source code. Also, it may be assumed that no attribute value is specified for the annotation "@Scope" as shown in FIG. 16(c), or that the annotation "@Scope" is not added as shown in FIG. 16(d). In such a case, the default setting is applied as the scope. Therefore, in such a case, the information processing device 100 may determine whether or not a singleton is applied to the target source code depending on whether or not the default setting means that a singleton is applied. Specifically, in the examples shown in FIG. 16(c) or FIG. 16(d), if the default setting means that a singleton is applied, the information processing device 100 determines that a singleton is applied to the target source code.

[0078] As another example, Fig. 17 is a diagram showing an example of a mechanism for determining whether or not a singleton is applied to a source code based on a scope-related setting defined in a configuration file associated with the target source code by a framework. In the example shown in Fig. 17, whether or not a singleton is applied is shown according to whether or not an attribute indicated by the keyword "scope", which means the specification of the scope of the program realized by the target source code, is specified for the "bean" tag that specifies various settings for each class, and the attribute value specified for the attribute. Specifically, as shown in FIG. 17(a) and FIG. 17(b), an attribute value is specified for the "scope" attribute of the "bean" tag, and the scope of the target source code is determined according to the attribute value. In addition, when "singleton", which means the application of a singleton, is specified as the attribute value for this "scope" attribute, it means that the singleton is applied to the target source code. That is, in the example shown in FIG. 17(a), the "scope" attribute means that the singleton is not applied. Also, in the example shown in FIG. 17(b), the "scope" attribute means that the singleton is applied. Therefore, the information processing device 100 may refer to a configuration file associated with the target source code, and determine whether or not a singleton is applied to the class indicated by the "bean" tag (in other words, the source code of the class) based on the attribute value specified for the "scope" attribute of the "bean" tag in the configuration file. Also, as shown in FIG. 17(c), a case may be assumed where the "scope" attribute is not specified for the "bean" tag. In such a case, a default setting is applied as the scope. Therefore, in such a case, the information processing device 100 may determine whether or not a singleton is applied to the target source code depending on whether or not the default setting means that a singleton is applied. Specifically, in the case of the example shown in FIG. 17(c), if the default setting means that a singleton is applied, the information processing device 100 determines that a singleton is applied to the target source code.

[0079] Next, an example of a method for updating a source code to be analyzed by the information processing device 100 according to the present embodiment will be described with reference to FIG. 18. In FIG. 18, source code C501 is a schematic representation of a source code to be analyzed. Although not shown in FIG. 18, it is assumed that class A and class B are separately defined, as in the example described with reference to FIG. 6 and FIG. 7. It is also assumed that class X is defined as having a field b in which an object of class B inheriting class A is held, and that a predetermined annotation (@Autowired) is indicated for the field. Although not shown in FIG. 18, an execution code (Main class) that is a starting point for generating a call graph for the updated source code C501 is separately added.

[0080] The analysis unit 111 of the information processing device 100 extracts source code C501 to which a predetermined annotation (@Autowired) is added from a series of source codes designated as an analysis target, and identifies the code (field) to which the annotation is indicated as the code to be updated (in other words, the update location). In the example shown in FIG. 18, it is assumed that the field b in which an object of class B inheriting class A is set is identified as the code to be updated. Then, the update unit 112 of the information processing device 100 adds code that indirectly indicates the generation of an object indicated by the code, based on the identification result of the code to be updated. Specifically, the update unit 112 adds an abstract class C503 corresponding to the code to be updated to the same project (hereinafter referred to as project 1) as the source code C501, and then adds a code for calling a generation process of a target object to the abstract class C503. In the example shown in FIG. 18, for convenience, the code C508 and the code C509 are illustrated for the source code C503. The code C508 is a code (overridden code) whose substantial process is defined as the code C506 in the source code C502 described later. The code C509 is a code (overridden code) whose substantial process is defined as the code C507 in the source code C502. When the singleton is applied, both the codes C508 and C509 are used. On the other hand, when the singleton is not applied, only the code C509 is used. Based on the result of determining whether a singleton has been applied to source code C501, the update unit 112 may selectively switch the output of code C508 and C509 as described above, or may add both regardless of whether a singleton has been applied or not. Furthermore, the update unit 112 adds code for calling the above-mentioned processing of the generated abstract class C503 to the code to be updated (field b) in the source code C501. For convenience, the example shown in Fig. 18 illustrates code C504 when a singleton is applied to the source code C501 and code C505 when a singleton is not applied to the source code C501. The update unit 112 adds either code C504 or C505 to the source code C501 based on the determination result of whether or not a singleton is applied to the source code C501.

[0081] Furthermore, the update unit 112 generates a project (hereinafter also referred to as project 3) different from project 1 including the source code C501 to be analyzed, and adds a class C502 that inherits the abstract class C503 to the project 3. Specifically, the update unit 112 adds to the class C502 a code of a process that is called by the code defined in the abstract class C503. As described above, either the code C508 (in the case of a singleton) or the code C509 (in the case of not being a singleton) is added to the abstract class C503 depending on whether or not a singleton is applied to the source code C501. Therefore, the update unit 112 appropriately changes the code to be added to the class C502 depending on the code added to the abstract class C503. In the example of source code C502 shown in FIG. 18, for convenience, a state in which both code C506 and code C507 are added to source code C501 is illustrated. Specifically, code C506 is added with a code for returning an object of class B (class inheriting class A) held in field b. In addition, the field b holds an object of class B generated (newed) by code C507, the details of which will be described later. In addition, code C507 is added with a code for generating an object of class B (class inheriting class A). When a singleton is applied, both codes C506 and C507 are used. On the other hand, when a singleton is not applied, only C507 is used. The update unit 112 may selectively switch the output of codes C506 and C507 as described above based on the result of determining whether a singleton is applied or not, or may add both codes regardless of whether a singleton is applied or not. Needless to say, it is desirable to switch the control relating to the output of this code in conjunction with the switching of control relating to the output of codes C508 and C509 in source code C503. Although not shown in the example shown in Fig. 18, an execution code (Main class) that serves as a starting point for generating a call graph for the updated source code C501 is added to project 3, based on the same technical idea as in the examples described with reference to Fig. 2 and Fig. 8. Note that the execution code is similar to the examples shown in Fig. 2 and Fig. 8, so a detailed description thereof will be omitted.

[0082] In this manner, by updating the source code to be analyzed, it becomes possible to output a call graph for that source code in a manner more in line with reality, depending on whether or not a singleton is applied to that source code. In the above example, an example has been described in which the information processing device 100 determines whether or not a singleton is applied to the source code to be analyzed based on annotations added to the source code to be analyzed, a configuration file associated with the source code, and the like. On the other hand, as long as the information processing device 100 can determine whether or not a singleton is applied to the source code to be analyzed, the method is not particularly limited. For example, the information processing device 100 may receive an instruction from a user and determine whether or not a singleton is applied to the target source code based on the instruction.

[0083] <Supplementary Information> In each embodiment of the present disclosure, the description focuses mainly on the case where the source code defined in a programming language called Java is the target of analysis, but the target programming language is not particularly limited as long as the source code is defined in a programming language that involves the generation of objects. As a specific example, the technology according to the present disclosure can be applied to source code defined in C++, Objective-C, etc. In that case, since the method of writing code differs depending on the programming language applied to the source code to be analyzed, it goes without saying that the code to be added or modified when updating the target source code is also appropriately changed according to the rules of the programming language.

[0084] Furthermore, the above-described embodiment is merely an example and does not necessarily limit the configuration or processing of the present invention. Various modifications and changes may be made without departing from the technical spirit of the present invention.

[0085] In addition, the following configurations also fall within the technical scope of the present disclosure. (1) An information processing device comprising: an extraction means for extracting a first source code in which a first field of an object is defined based on at least one of an annotation added to a source code that suggests the generation of an object from a series of source codes to be analyzed and a definition of the object to be generated in a configuration file associated with the series of source codes; and a generation means for generating a second source code different from the first source code in which a code that directly indicates the generation of an object corresponding to the first field is defined, and an execution code that invokes a process that references the first field defined in the first source code by invoking a process defined in the second source code; wherein a call graph is generated based on the first source code, the second source code, and the execution code. (2) An information processing device as described in (1), further comprising an update means for updating the first source code by adding code to the first source code that indirectly indicates the generation of the object, wherein the generation means generates the second source code in which code that directly indicates the generation of the object is defined, in association with the code that indirectly indicates the generation of the object, and generates the execution code so as to call a process defined in the updated first source code by calling a process defined in the second source code. (3) the code indirectly indicating the generation of the object is a code for invoking a process defined in an abstract class of a class defined in the second source code; The information processing device according to (2), wherein the class is defined in the second source code so as to inherit the abstract class. (4) The information processing device described in (1), wherein the generation means generates the second source code that defines a second field corresponding to the object, code for generating the object and storing it in the second field, and code for returning the object stored in the second field in response to a call, and generates the execution code to call the object generated by processing defined in the second source code and to call processing defined in the first source code as processing of the object. (5) When the first source code in which the first field of a first object is defined and a third source code in which a second field of a second object, which has a different management unit from the first source code and is defined depending on the first source code, are extracted, the generating means generates a fourth source code in which a third field corresponding to the second object, code for generating the second object and storing the second object in the third field, and code for returning the second object stored in the third field in response to a call, the second field corresponding to the first object, and the fourth source code in which a second field of a second object, which has a different management unit from the first source code and is defined depending on the first source code, are defined. the second source code in which is specified code for retaining the second object as the first object in the second field based on a call of code for returning the second object held in the third field specified in the second source code, and code for returning the first object held in the second field in response to the call; and the execution code for calling an object generated by a process specified in the second source code, and calling, as processing of the object, the process specified in the first source code and the process specified in the third source code. (6) An information processing method executed by an information processing device, comprising: an extraction step of extracting a first source code in which a first field of an object is defined based on at least one of an annotation added to a source code that suggests the generation of an object from a series of source codes to be analyzed and a definition of the object to be generated in a configuration file associated with the series of source codes; and a generation step of generating a second source code that defines a code that directly indicates the generation of an object corresponding to the first field and is different from the first source code, and an execution code that invokes a process that references the first field defined in the first source code by invoking a process defined in the second source code, wherein a call graph is generated based on the first source code, the second source code, and the execution code. (7) A program for causing a computer to execute the following steps: extracting a first source code in which a first field of an object is defined based on at least one of an annotation added to a source code that suggests the generation of an object from a series of source codes to be analyzed and a definition of the object to be generated in a configuration file associated with the series of source codes; and generating a second source code different from the first source code in which a code that directly indicates the generation of an object corresponding to the first field is defined, and an execution code that calls a process that references the first field defined in the first source code by calling a process defined in the second source code; and generating a call graph based on the first source code, the second source code, and the execution code. [Explanation of symbols]

[0086] 100 Information processing device 110 Control section 111 Analysis Department 112 Update Department 120 Call graph generator

Claims

1. an extraction means for extracting a first source code in which a first field of an object is defined based on at least one of an annotation that suggests the generation of an object added to the source code from a series of source codes to be analyzed and a definition of the object to be generated in a configuration file associated with the series of source codes; a generating means for generating a second source code, the second source code being different from the first source code and including a code that directly indicates the generation of an object corresponding to the first field; and an execution code that calls a process that refers to the first field, the process being defined in the first source code by calling a process defined in the second source code; Equipped with A call graph is generated based on the first source code, the second source code, and the execution code. Information processing device.

2. an updating means for updating the first source code by adding a code indirectly indicating generation of the object to the first source code; The generating means includes: generating the second source code in which a code that directly indicates the creation of the object is defined in association with a code that indirectly indicates the creation of the object; generating the execution code so as to call a process defined in the second source code, thereby calling a process defined in the updated first source code; The information processing device according to claim 1 .

3. the code indirectly indicating the generation of the object is a code for invoking a process defined in an abstract class of a class defined in the second source code, The class is defined in the second source code so as to inherit the abstract class. The information processing device according to claim 2 .

4. The generating means includes: generating the second source code, the second source code defining a second field corresponding to the object, code for generating the object and storing it in the second field, and code for returning the object stored in the second field in response to a call; generating the execution code so as to call the object generated by the process defined in the second source code and to call the process defined in the first source code as the process of the object; The information processing device according to claim 1 .

5. The generating means includes: When the first source code in which the first field of a first object is defined and a third source code in which a second field of a second object, which has a different management unit from that of the first source code and is defined depending on the first source code, are extracted, a fourth source code defining a third field corresponding to the second object, code for generating the second object and storing the second object in the third field, and code for returning the second object stored in the third field in response to a call; the second source code defining the second field corresponding to the first object, code for holding the second object in the second field as the first object based on a call of code for returning the second object held in the third field defined in the fourth source code, and code for returning the first object held in the second field in response to the call; the execution code calling an object generated by a process defined in the second source code, and calling, as a process of the object, a process defined in the first source code and a process defined in the third source code; Generate The information processing device according to claim 4.

6. An information processing method executed by an information processing device, an extraction step of extracting a first source code in which a first field of an object is defined based on at least one of an annotation that suggests the generation of an object added to the source code from the series of source codes to be analyzed and a definition of the object to be generated in a configuration file associated with the series of source codes; a generating step of generating a second source code, the second source code being different from the first source code and including a code that directly indicates generation of an object corresponding to the first field, and an execution code that calls a process that refers to the first field, the process being defined in the first source code by calling a process defined in the second source code; Including, A call graph is generated based on the first source code, the second source code, and the execution code. Information processing methods.

7. On the computer, an extraction step of extracting a first source code in which a first field of an object is defined based on at least one of an annotation that suggests the generation of an object added to the source code from the series of source codes to be analyzed and a definition of the object to be generated in a configuration file associated with the series of source codes; a generating step of generating a second source code, the second source code being different from the first source code and including a code that directly indicates generation of an object corresponding to the first field, and an execution code that calls a process that refers to the first field, the process being defined in the first source code by calling a process defined in the second source code; Run the command, A call graph is generated based on the first source code, the second source code, and the execution code. program.

Citation Information

Patent Citations

  • UML design method

    JP2005327094A

  • Migrating computer programs to virtual compute services using annotations

    US10782934B1

  • Profile guided optimization in the presence of stale profile data

    US20160004518A1

  • Call graph creation device, call graph creation method, and program

    WO2022123763A1