CN116974653B - Class loading method and system - Google Patents

Class loading method and system Download PDF

Info

Publication number
CN116974653B
CN116974653B CN202311228738.9A CN202311228738A CN116974653B CN 116974653 B CN116974653 B CN 116974653B CN 202311228738 A CN202311228738 A CN 202311228738A CN 116974653 B CN116974653 B CN 116974653B
Authority
CN
China
Prior art keywords
class
information
target
loading
loaded
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311228738.9A
Other languages
Chinese (zh)
Other versions
CN116974653A (en
Inventor
陈刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Cloud Computing Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Cloud Computing Ltd filed Critical Alibaba Cloud Computing Ltd
Priority to CN202311228738.9A priority Critical patent/CN116974653B/en
Publication of CN116974653A publication Critical patent/CN116974653A/en
Application granted granted Critical
Publication of CN116974653B publication Critical patent/CN116974653B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the specification provides a class loading method and a class loading system, wherein the class loading method comprises the following steps: generating an executable code file containing a class to be loaded and a class loader corresponding to the class to be loaded according to the initial class loading information, and determining a class loading view corresponding to the class loader; establishing a mapping relation between the class to be loaded and a view window in the class loading view; and under the condition that the class loader is called and the target class to be loaded contained in the executable code file is loaded, determining a target view window corresponding to the target class to be loaded based on the mapping relation, and recording class loading information of the target class to be loaded at a storage position corresponding to the target view window.

Description

Class loading method and system
Technical Field
The embodiment of the specification relates to the technical field of computers, in particular to a class loading method and system.
Background
With the development of internet technology, the requirements on efficiency are gradually increased in a fast-paced living environment. Under the application program running scene, the elastic capability requirement of the application program is higher and higher, and the important point of affecting the elastic capability is that the cold start speed of the application program is required to be fast enough. In the face of the proliferation of access volume, new services can be created to cope with the increase in traffic in a short time.
In the prior art, a preloading mode is generally adopted to realize the early start of an application program and realize the early establishment of a service. However, this method cannot be implemented for a specific program language, and loading errors easily occur when the application program is loaded in advance, so that the application program cannot provide services, and the application program is slow to start in the process of repairing the application program, so that an effective method is needed to solve the above-mentioned problems.
Disclosure of Invention
In view of this, the present embodiments provide a class loading method. One or more embodiments of the present specification relate to a class loading apparatus, a class loading system, a computing device, a computer-readable storage medium, and a computer program that solve the technical drawbacks of the prior art.
According to a first aspect of embodiments of the present disclosure, there is provided a class loading method, applied to a server, including:
generating an executable code file containing a class to be loaded and a class loader corresponding to the class to be loaded according to the initial class loading information, and determining a class loading view corresponding to the class loader;
establishing a mapping relation between the class to be loaded and a view window in the class loading view;
And under the condition that the class loader is called and the target class to be loaded contained in the executable code file is loaded, determining a target view window corresponding to the target class to be loaded based on the mapping relation, and recording class loading information of the target class to be loaded at a storage position corresponding to the target view window.
According to a second aspect of embodiments of the present specification, there is provided a class loading device, for application to a server, comprising:
the determining module is configured to generate an executable code file containing a class to be loaded and a class loader corresponding to the class to be loaded according to the initial class loading information, and determine a class loading view corresponding to the class loader;
the mapping relation establishing module is configured to establish a mapping relation between the class to be loaded and a view window in the class loading view;
the loading module is configured to determine a target view window corresponding to the target class to be loaded based on the mapping relation under the condition that the class loader is called and the target class to be loaded contained in the executable code file is loaded, and record class loading information of the target class to be loaded at a storage position corresponding to the target view window.
According to a third aspect of embodiments of the present specification, there is provided a class loading system comprising a server and a client;
the server responds to a page information acquisition request submitted by the client for an initial page to determine a code file to be executed; generating an executable code file containing a class to be loaded and a class loader corresponding to the class to be loaded according to the initial class loading information, and determining a class loading view corresponding to the class loader; establishing a mapping relation between the class to be loaded and a view window in the class loading view; under the condition that the class loader is called and a target class to be loaded contained in the executable code file is loaded, determining a target view window corresponding to the target class to be loaded based on the mapping relation, and recording class loading information of the target class to be loaded at a storage position corresponding to the target view window; under the condition that the loading of the target class to be loaded is completed, generating executable class codes corresponding to the target class to be loaded and storing the executable class codes into a target storage space; under the condition that a page update request submitted by the client is received, determining a target executable code corresponding to the page update request in the target storage space and feeding back to the client;
And the client updates the initial page based on the target executable code.
According to a fourth aspect of embodiments of the present specification, there is provided a computing device comprising:
a memory and a processor;
the memory is configured to store computer-executable instructions that, when executed by the processor, perform the steps of the class loading method described above.
According to a fifth aspect of embodiments of the present specification, there is provided a computer readable storage medium storing computer executable instructions which, when executed by a processor, implement the steps of the class loading method described above.
According to a sixth aspect of the embodiments of the present specification, there is provided a computer program, wherein the computer program, when executed in a computer, causes the computer to perform the steps of the class loading method described above.
According to one embodiment of the specification, an executable code file containing a class to be loaded and a class loader corresponding to the class to be loaded are generated according to initial class loading information, and a class loading view corresponding to the class loader is determined; establishing a mapping relation between a class to be loaded and a view window in a class loading view; and under the condition of calling a class loader and loading the target class to be loaded contained in the executable code file, determining a target view window corresponding to the target class to be loaded based on the mapping relation, and recording class loading information of the target class to be loaded in a storage position corresponding to the target view window. By generating the class loader corresponding to the class to be loaded based on the class loader information, determining the class loading view corresponding to the class loader, and establishing the mapping relation between the class to be loaded and the view window in the class loading view, the association relation among the class to be loaded, the class loader and the class loading view is constructed, so that the accuracy of class loading can be ensured on the basis of dynamic loading of the class when the class to be loaded is loaded subsequently. By constructing the association relation among the class to be loaded, the class loader and the class loading view, the code file to be executed can be compiled in advance in a dynamic class loading mode, and therefore the starting speed of the application program is improved.
Drawings
FIG. 1 is a schematic diagram of a loading-like method according to one embodiment of the present disclosure;
FIG. 2 is a flow chart of a class loading method provided by one embodiment of the present description;
FIG. 3 is a class loading description file generation schematic diagram of a class loading method provided by one embodiment of the present disclosure;
FIG. 4 is a class loading diagram of a class loading method provided by one embodiment of the present disclosure;
FIG. 5 is a process flow diagram of a class loading method provided by one embodiment of the present disclosure;
FIG. 6 is a schematic diagram of a loading device of the type provided in one embodiment of the present disclosure;
FIG. 7 is a schematic diagram of a loading system of the type provided in one embodiment of the present disclosure;
FIG. 8 is a block diagram of a computing device provided in one embodiment of the present description.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present description. This description may be embodied in many other forms than described herein and similarly generalized by those skilled in the art to whom this disclosure pertains without departing from the spirit of the disclosure and, therefore, this disclosure is not limited by the specific implementations disclosed below.
The terminology used in the one or more embodiments of the specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the specification. As used in this specification, one or more embodiments and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present specification refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that, although the terms first, second, etc. may be used in one or more embodiments of this specification to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first may also be referred to as a second, and similarly, a second may also be referred to as a first, without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
Furthermore, it should be noted that, user information (including, but not limited to, user equipment information, user personal information, etc.) and data (including, but not limited to, data for analysis, stored data, presented data, etc.) according to one or more embodiments of the present disclosure are information and data authorized by a user or sufficiently authorized by each party, and the collection, use, and processing of relevant data is required to comply with relevant laws and regulations and standards of relevant countries and regions, and is provided with corresponding operation entries for the user to select authorization or denial.
First, terms related to one or more embodiments of the present specification will be explained.
JVM: the Java virtual machine is a specification for a computing device, is a fictitious computer, and is implemented by simulating the functions of an analog computer on an actual computer.
Class loading: the Java file obtains a class file containing Java classes through a compiler. The class file is loaded into the JVM by the class loader corresponding to Java. The class loader acts as class loading.
AOT: aheadofTime (advanced compilation) compiles code into native code of the target architecture, thereby reducing the runtime overhead.
GOT: global offset table (global offset table) for locating global variables and functions, and the relocatable of symbols is realized by means of relative offset.
JIT: just in time (just in time) is a technique to compile and execute code at runtime.
QPS: query Per Second (Query rate Per Second), QPS, is a measure of how much traffic a particular Query server handles in a specified time.
In a practical application scenario, the requirement on the elastic capability of an application program is higher and higher, and one key factor affecting the elastic capability is the cold start speed. The speed of application cold start needs to be fast enough. For example, an online service system, the majority of the time has a low access, i.e., 10QPS. But perhaps for a certain period of time, the access volume will reach 100QPS, and in the case of a request volume increase from 10 to 100QPS within 1 minute, a new service needs to be created within 1 minute to cope with the increase in traffic, and if this application is cold started for 3 minutes, it is obviously impossible to complete the creation of the service within 1 minute. But if the application can complete the start-up within 30 seconds, then the surge in flow can be handled within 1 minute. The above problems can be overcome by compiling this technique in advance. The CPU overhead is reduced by compiling the codes into the codes of the specific target machines in advance, so that the starting speed is improved. The advanced compiling is a technology for reducing the memory and CPU overhead in the running process and improving the running performance of the program by compiling the code into the code of the target architecture. Advanced compilation is generally not able to support dynamic class loading, which results in the application not being able to use advanced compilation. Accordingly, there is a need for an effective method to solve the above-mentioned problems.
Fig. 1 is a schematic structural diagram of a class loading method according to an embodiment of the present disclosure, where, as shown in fig. 1, a code file to be executed is determined when class loading is performed, and class loading description information and class loader information are determined according to class code included in the code file to be executed. And performing preliminary compiling on the code file to be executed to obtain a compiling file, determining class codes in the compiling file based on the class loading description information, compiling, and determining the executable code file containing the class to be loaded according to the compiling result. And constructing a class loader corresponding to the class to be loaded based on the class loader information, and determining a class loading view corresponding to the class loader. And establishing a mapping relation between the class to be loaded and a view window in the class loading view. And under the condition of calling a class loader and loading the target class to be loaded contained in the executable code file, determining a target view window corresponding to the target class to be loaded based on the mapping relation, and recording class loading information of the target class to be loaded in a storage position corresponding to the target view window. Under the condition that class codes to be loaded in executable codes are loaded completely, the advanced compiling is completed, and therefore the execution speed of subsequent tasks is improved.
By generating the class loader corresponding to the class to be loaded based on the class loader information, determining the class loading view corresponding to the class loader, and establishing the mapping relation between the class to be loaded and the view window in the class loading view, the association relation among the class to be loaded, the class loader and the class loading view is constructed, so that the accuracy of class loading can be ensured on the basis of dynamic loading of the class when the class to be loaded is loaded subsequently. By constructing the association relation among the class to be loaded, the class loader and the class loading view, the code file to be executed can be compiled in advance in a dynamic class loading mode, and therefore the starting speed of the application program is improved.
In the present specification, a class loading method is provided, and the present specification relates to a class loading apparatus, a class loading system, a computing device, and a computer-readable storage medium, which are described in detail in the following embodiments one by one.
Referring to fig. 2, fig. 2 shows a flowchart of a class loading method according to an embodiment of the present disclosure, which specifically includes the following steps.
Step S202: and generating an executable code file containing the class to be loaded and a class loader corresponding to the class to be loaded according to the initial class loading information, and determining a class loading view corresponding to the class loader.
Specifically, the initial class loading information may be information representing an attribute of a class to be loaded, or may be information for creating a class loader, including, but not limited to, name information, type information, and memory identification information of the class loader; the class to be loaded refers to a class to be loaded in the code file to be executed, so that the corresponding function of the code file to be executed can be realized conveniently. The class loader is used for realizing class loading, can load Java classes into a to-be-virtualized machine and is used for realizing instantiation of the Java classes; accordingly, the class loading view is a class loading view allocated to the class loader when the class loader is created, and is used for recording class loading information when the subsequent class loading is performed.
Based on the method, initial class loading information is acquired, an executable code file containing the class to be loaded is generated based on the initial class loading information, and a class loader corresponding to the class to be loaded in the executable code file is generated. And determining a class loading view corresponding to the class loader. The class loader is used for loading the class to be loaded based on the class loading view and the class loader.
Further, considering that executable code files need to be obtained through compiling, and different executable code files correspond to different class loaders, initial class loading information needs to be determined based on the basis of the code files to be executed, and then a class loading view is determined, which is specifically implemented as follows:
Determining the initial class loading information according to a code file to be executed, and compiling the code file to be executed into a compiling file; determining class codes in the compiling file based on the class loading description information in the initial class loading information, compiling, and determining an executable code file containing the class to be loaded according to a compiling result; generating a class loader corresponding to the class to be loaded based on the class loader information in the initial class loading information, and determining a class loading view corresponding to the class loader.
Specifically, the code file to be executed refers to a code file edited by a developer and is used for realizing a function corresponding to a code, and the code file to be executed can be a code file edited in the process of application program development and website development and can be a code file obtained by editing through a code editor; the class loading description information refers to class address information and class attribute information determined based on class codes contained in the code file, the class loading description information is class metadata, and the class attribute information comprises but is not limited to class name information; the class loader information refers to name information, type information and memory identification information of a class loader for loading the class, which are recorded in a code file to be executed by the class; the compiling refers to a process of generating a target program from a source program written in a source language by utilizing a compiler, wherein the compiling can be understood as converting a high-level language into a binary language which can be identified by a computer, and a compiling file is a compiling result obtained after compiling a code file to be executed; the class code is a code corresponding to the class loading description information, and refers to a complete code of a class corresponding to the class attribute information contained in the class loading description information; compilation refers to the process of generating a target program from a source program written in a source language using a compiler, i.e., translating a file of code to be executed written in a high-level programming language into equivalent machine language format code, for example, compiling code to be executed written in a Java generation language into machine language code.
Based on this, at the time of class loading, a code file to be executed is determined. And determining class codes contained in the code files to be executed according to the code files to be executed, determining class attribute information, class geological information and other class loading description information corresponding to the class codes, and determining class loader information based on the code files to be executed. And performing preliminary compiling on the code file to be executed, and compiling the code file to be executed into a compiling file. Based on class attribute information such as class name information and class address information contained in the class loading description information, determining class codes in the compiling file, compiling codes in the compiling file containing the class codes, and determining an executable code file containing the class to be loaded according to the compiling result. Generating a class loader corresponding to the class to be loaded contained in the executable code file based on the class loader information, determining a class loading view corresponding to the class loader, wherein the class loading view contains a plurality of view windows and is used for recording class loading information of the class to be loaded when the class to be loaded is loaded.
In practical application, the code file to be executed contains at least one class code, and before compiling the code file to be executed, the class loading description information and the class loader information need to be determined according to the code file to be executed, namely, the code file to be executed in the code file to be executed is operated, the class code contained in the code file to be executed is determined, the class loading description information corresponding to the class code is recorded, and the class loader information is recorded.
For example, in a webpage loading scenario, class loading is not required to be implemented based on a code file to be executed corresponding to a webpage every time the webpage is loaded. After determining the code file to be executed corresponding to the webpage, generating description information during class loading based on the code file to be executed, and compiling the code file to be executed based on the description information to obtain a compiling file. And compiling the class codes in the compiled file. And generating a class loader corresponding to the class to be loaded, and constructing a class loading view.
In summary, the initial class loading information is determined according to the code file to be executed, and then the executable code file is determined based on the initial class loading information, so as to generate a class loader and determine a class loading view. Thus, the preparation before loading the class to be loaded is realized, and the subsequent class loading is successfully completed.
Further, considering that more class codes are contained in the code file to be executed, each class code corresponds to different names and code positions, when the class is loaded, not each class needs to be loaded, in order to facilitate description of the class codes contained in the code file to be executed, the accuracy of loading of subsequent classes is improved, statistics can be carried out on the class codes contained in the code file to be executed, and a class loading description file is generated, which is specifically implemented as follows:
Generating a class loading description file based on the code file to be executed; and reading the class loading description information and the class loader information in the class loading description file, and taking the class loading description information and the class loader information as the initial class loading information.
Specifically, metadata of class codes to be executed in a code file to be executed, class loading rule information and class loader information are recorded in a class loading description file, wherein the metadata of the class codes comprise, but are not limited to, information such as names of the classes, code positions of the classes and the like; class loading rule information indicates that for a rule-compliant class, loading is performed at a specified location by a specified class loader, e.g., for a class with package name com.Fool, loading is performed at the location/WEB/INF/lib by a class loader with name C1.
Based on this, the class code to be executed contained in the code file to be executed is determined, and a class loading description file is generated based on the class attribute information and the class address information of the class code to be executed and the class loader information contained in the code file to be executed. And reading class loading description information and class loader information containing class attribute information and class address information from the class loading description file, and taking the class loading description information and the class loader information as the initial class loading information so as to facilitate the subsequent class loading.
Along the above example, the server compiles the code file to be executed in advance when the webpage is loaded, so as to realize the pre-generation of the executable code corresponding to the webpage. As the webpage can contain a plurality of functional portals such as news, automobiles, pictures, shopping and the like, each functional module can correspond to an independent class loader, the isolation of class loading is realized, and the problem of class loading errors under the condition that classes have the same name is avoided. When codes corresponding to news are compiled in advance, determining a code file to be executed corresponding to the news, and determining class codes to be loaded in the code file to be executed. A class loading description file is generated based on the name of the class code, the code location and the class loader name, and the name of the class code, the code location and the class loader name in the class loading description file are used for realizing subsequent class loading.
In summary, the class loading description file is generated based on the code file to be executed, and then the code in the code file to be executed can be compiled based on the class loading description file, so that the compiling of the effective code is realized, the compiling accuracy is improved, and the waste of resources is reduced.
Further, considering that the number of class codes contained in the code file to be executed is large, the class loading rule is complex, so that the class code to be executed can be recorded in a mode of generating the class loading description file corresponding to the code file to be executed, and the method is used for subsequent class loading, and is specifically realized as follows:
Determining initial class loader information, class attribute information and class address information of class codes to be executed in a code file to be executed; generating class loading description information from the class attribute information and the class address information; generating target class loader information according to the class loading description information and the initial class loader information, and taking the target class loader information as class loader information corresponding to the class code to be executed; and generating a class loading description file based on the class loading description information and the class loader information.
Specifically, the initial class loader information refers to name information, type information and memory identification information of a class loader recorded in a code file to be executed, and the memory identification information of the class loader; class attribute information refers to class name information of class codes to be executed; the address information refers to code position information of a class of the class code to be executed; the target class loader information refers to class name information and class loading rule information generated based on class loader information, class attribute information, and class address information.
Based on the information, determining the class code to be executed contained in the code file to be executed, determining class attribute information and class address information according to the name information and the position information of the class code to be executed, and determining initial class loader information of the class code to be executed according to the code file to be executed. Class loading description information is generated based on the class attribute information and the class address information. And integrating the class loading description information and the initial class loader information to generate target class loader information, or generating the target class loader information based on the class loading description information or the initial class loader information.
In summary, the class loader information is determined according to the class loading description information and the initial class loader information, so that the class loader information is matched with the class code to be executed, the readability of the class loader information is improved, and the subsequent class loading is facilitated.
Further, considering the readability of the class loader information, the class loader information may be generated based on the class loading description information and the initial class loader information, and the specific implementation is as follows:
generating at least two candidate class loader information according to the class loading description information and the initial class loader information; selecting target class loader information from at least two candidate class loader information according to a preset selection rule, and taking the target class loader information as class loader information corresponding to the class code to be executed.
Specifically, the candidate class loader information refers to the selectable class loader information with readability generated based on the name information, the type information and the memory identification information of the class loader; the selection rule can be that the degree of distinction, the frequency of occurrence of vocabulary and class loader types are selected according to the information length; correspondingly, the target class loader information is one candidate class loader information selected from at least two candidate class loader information.
Based on the class name information and the class address information in the class loading description information, and class loader name information, type information and memory identification information in the initial class loader information, at least two candidate class loader information are generated. According to a preset selection rule, selecting target class loader information with readability from at least two candidate class loader information, and taking the target class loader information as class loader information corresponding to class codes to be executed.
Along the above example, the class loader name may be formulated according to the name information, the location information, and the information of the class loader. And formulating a plurality of candidate class loading names of ab/jsgd/suw/hgsg, jis/hihs/h9isb/his and the like, so that one class loader name corresponding to the class code to be executed is selected from the plurality of candidate class loading names.
In summary, at least two candidate class loader information is generated according to the class name information and the class address information in the class loading description information and the class loader name information, the type information and the memory identification information in the initial class loader information, so that target class loader information with readability is selected from the at least two candidate class loader information, the name readability of the class loader is improved, and the searching and modifying tasks are conveniently executed.
Further, since at least two candidate class loader information is determined and one of the at least two candidate class loader information needs to be selected as the class loader information, the unselected candidate class loader information is deleted, which is specifically implemented as follows:
and deleting candidate class loader information except the target class loader information in the at least two candidate class loader information.
Based on the method, after the target class loader information is selected from the at least two candidate class loader information, the candidate class loader information except the target class loader information in the at least two candidate class loader information can be determined and deleted, so that the purposes of releasing the storage space and deleting the invalid candidate class loader information are achieved.
Along the above examples, fig. 3 is a class loading description file generation schematic diagram of a class loading method according to an embodiment of the present disclosure; as shown in fig. 3, in the webpage loading scenario, code files to be executed corresponding to each function in the webpage are determined. And under the condition that the class loading description file of the news function is generated, determining the code file to be executed corresponding to the news function. A recording stage, recording class metadata contained in a code file to be executed and memory identification information corresponding to a class loader; in the precompiled preparation stage, the class data, the class loader and the code source are determined, the code source is aggregated to the dimension of the class loader, the initial allocation of class loading rules is realized, the loading optimization of package rules is realized, and the readability of the rules is improved. And deleting the invalid null rule. And allocating readable names to class loaders, allocating piece code sources and resolving conflicts, namely establishing a relation between the class loaders and class codes, and generating class loading description files, wherein class loading is realized based on the class loading description files in the stage of compiling classes and method selection, and unloaded classes in code files to be executed and methods without compiling are filtered.
In summary, by deleting candidate class loader information except for the target class loader information in the at least two candidate class loader information, release of the storage space is realized, and invalid candidate class loader information is deleted.
Further, when an application program or a webpage is opened, since the real-time compiling of the code and the loading of the class will lead to the extension of the waiting time, the method can be realized by performing the advanced compiling of the code and the advanced loading of the class corresponding to the function when the application program or the webpage is opened for the first time, which is as follows:
receiving an information acquisition request submitted by a client for a target task; analyzing the information acquisition request, determining target information corresponding to the target task according to an analysis result, and sending the target information serving as feedback of the information acquisition request to the client; and determining the code to be executed based on the target information, and executing the class loading description information and the class loader information determined according to the code file to be executed.
Specifically, the target task may be an application program starting task, a web page starting task, and a code testing task for a program; the information acquisition request is a computer instruction which corresponds to the target task and is used for acquiring information, and when the target task is a webpage starting task, the information acquisition request is a computer instruction for acquiring related information of a webpage top page; correspondingly, the target information is the information such as pictures, characters and the like for generating the first page of the webpage.
Based on the above, under the condition that an information acquisition request submitted by the client for the target task is received, the information acquisition request is analyzed, target information corresponding to the target task is determined according to the analysis result, and the target information is fed back to the client as a response of the information acquisition request for the client to execute the target task. And determining the code to be executed associated with the target task based on the target information, and determining class loading description information and class loader information according to the code to be executed file.
Along the above example, when the target task is the loading task of the top page of the web page, the user where the client is located sends an information acquisition request to the server by clicking the form of the web page link or the icon, and the information acquisition request is used for generating the top page of the web page at the client. The server determines the code files to be executed corresponding to the functions of news, pictures, shopping and the like in the webpage at the moment, and realizes advanced compiling and dynamic loading of class codes based on the code files to be executed, so that the starting time consumption can be shortened when a user starts the functions of news, shopping and the like.
In summary, by determining the code to be executed associated with the target task when the information acquisition request submitted by the client for the target task is received, advanced compiling and dynamic loading of the class code are realized based on the code file to be executed, and when the function corresponding to the code file to be executed is started, starting time consumption can be reduced, and user experience is improved.
Step S204: and establishing a mapping relation between the class to be loaded and a view window in the class loading view.
Specifically, after the executable code file containing the class to be loaded and the class loader corresponding to the class to be loaded are generated according to the initial class loading information, and the class loading view corresponding to the class loader is determined, a mapping relationship between the class to be loaded and the view window in the class loading view can be established, wherein the mapping relationship refers to a corresponding relationship between the class to be loaded and the view window in the class loading view, that is, one view window is allocated to each class to be loaded, and is used for recording class loading information of the class to be loaded when the class to be loaded is loaded subsequently.
Based on the method, after a class loader corresponding to the class to be loaded is generated based on the class loader information, a class loading view corresponding to the class loader is determined, a view window contained in the class loading view is determined, the class to be loaded contained in the executable code file is determined, a view window is allocated for each class to be loaded, and the establishment of the mapping relation between the class to be loaded and the view window in the class loading view is realized.
In practical application, when determining the view window corresponding to the class to be loaded, the view window can be randomly allocated for the class to be loaded.
Step S206: and under the condition that the class loader is called and the target class to be loaded contained in the executable code file is loaded, determining a target view window corresponding to the target class to be loaded based on the mapping relation, and recording class loading information of the target class to be loaded at a storage position corresponding to the target view window.
Specifically, after the mapping relationship between the class to be loaded and the view window in the class loading view is established, under the condition that the class loader is called and the target class to be loaded contained in the executable code file is loaded, determining a target view window corresponding to the target class to be loaded based on the mapping relationship, and recording class loading information of the target class to be loaded in a storage position corresponding to the target view window, wherein the target class to be loaded refers to the class to be loaded which is determined in the executable code file and needs to be loaded; the target view window is a view window in a class loading view corresponding to the target class to be loaded, which is determined according to the mapping relation; the class loading information refers to recorded address information and class information of the class when loading the target class to be loaded, and is used for indicating that the target class to be loaded is loaded.
Based on the above, after the mapping relation between the class to be loaded and the view window in the class loading view is established, loading of the class to be loaded in the executable code file can be started. Determining a target class to be loaded in the executable code file, and under the condition of calling a class loader and loading the target class to be loaded contained in the executable code file, determining a target view window corresponding to the target class to be loaded in a class loading attempt based on a mapping relation, and recording class loading information of the target class to be loaded in a storage position corresponding to the target view window.
Further, considering that the target class to be loaded is not immediately used for the subsequent page update task after loading is completed, the target class to be loaded can be stored in the target storage space in the form of executable class codes, which is specifically implemented as follows:
and under the condition that the loading of the target class to be loaded is completed, generating executable class codes corresponding to the target class to be loaded and storing the executable class codes into a target storage space.
Specifically, the executable class code is a code capable of generating a page when executing, and is used for sending the executable class code to a client when the client has a page update requirement, and realizing page loading or updating at the client.
Based on the above, under the condition that the loading of the target class to be loaded is completed by the class loader, executable class codes corresponding to the target class to be loaded are generated, and the executable class codes are stored into the target storage space for the subsequent loading or updating of the page. When the target class to be loaded is loaded again, the target class to be loaded is loaded completely, so that the target class to be loaded does not need to be loaded again.
In summary, under the condition that loading of the target class to be loaded is completed by the class loader, executable class codes corresponding to the target class to be loaded are generated, and the executable class codes are stored into the target storage space, so that the target class to be loaded is loaded in advance, and the execution speed of subsequent tasks is improved.
Further, as the target class to be loaded has a corresponding class loading view window in the class loading view corresponding to the class loader. When the target class to be loaded is loaded for the first time, class loading information is stored in a storage position corresponding to the class loading view window, and when the target class to be loaded is loaded again, reloading is not needed. Therefore, when each class to be loaded is loaded, whether the class to be loaded is loaded can be judged, and the specific implementation is as follows:
Determining a target view window corresponding to the target class to be loaded based on the mapping relation, and judging whether storage information exists in a storage position corresponding to the target view window; if yes, executing the step of generating executable class codes corresponding to the target class to be loaded and storing the executable class codes into a target storage space under the condition that the loading of the target class to be loaded is completed; and if not, executing the step of recording class loading information of the target class to be loaded at the storage position corresponding to the target view window.
Specifically, the storage information refers to class loading information stored in a storage position corresponding to the view window when the class to be loaded is loaded.
Based on the above, determining a target view window corresponding to the target class to be loaded in the class loading view corresponding to the class loader based on the mapping relation. Judging whether storage information exists in a storage position corresponding to the target view window; if the storage position corresponding to the target view window has storage information, which indicates that the target class to be loaded is being loaded or has been loaded, executable class codes corresponding to the target class to be loaded can be generated and stored in the target storage space under the condition that the loading of the target class to be loaded is completed; if the storage position corresponding to the target view window does not have the storage information, the target class to be loaded is not loaded, so that class loading information of the target class to be loaded is recorded in the storage position corresponding to the target view window and used for representing a loading result of the target class to be loaded.
Along the above example, fig. 4 is a class loading schematic diagram of a class loading method according to an embodiment of the present disclosure, where, as shown in fig. 4, a class includes a Foo1 class, a BarI class, a Bar1 class, and a Bar2 class, and class loading is performed. The class loader 1 and the class loader 2 respectively correspond to the classes to be loaded, and the class loading view 1 and the class loading view 2. When class loading is completed, information related to the class is recorded in a storage position of a view window corresponding to the class in the class loading view. As can be seen from the figure, the class loader 1 corresponds to Foo1 class, bar1 class, and Bar2 class, and the class loader 2 corresponds to Bar i class, and Bar1 class. When the class loader 2 loads the class BarI, judging whether the storage position of a view window corresponding to the class BarI in the class loading view records related information of the class BarI, and if so, indicating that the class BarI is loaded; if not, the BarI class is loaded.
In summary, whether storage information exists in the storage position corresponding to the target view window is judged, so that whether the target class to be loaded needs to be loaded is determined, dynamic loading of the target class to be loaded is realized, and resource consumption of class loading is reduced.
Furthermore, because the number of classes to be loaded is large, the class loading information generated when each class to be loaded is loaded needs to be accurately recorded, and when the target class to be loaded is loaded, the class loading information can be recorded in the loading information table, so that the following specific implementation is realized:
determining a loading information table corresponding to the class loader; the recording the class loading information of the target class to be loaded at the storage position corresponding to the target view window comprises the following steps: determining a storage position corresponding to the target view window in the loading information table; determining initial address information and class information in the target class to be loaded, and determining target address information based on the initial address information and a window address corresponding to the target view window; and storing the target address information and the class information as the class loading information to the storage position.
Specifically, the loading information table refers to a global offset table corresponding to class loading, and is used for recording class loading information generated when the class to be loaded is loaded; the initial address information refers to the address information of the class recorded in the target class to be loaded; class information refers to name information of a class; the window address refers to the address information of the target view window; correspondingly, the target address information is the offset address which is determined after calculation and is used for being stored in the storage position.
Based on this, a loading information table corresponding to the class loader is determined. And determining a storage position corresponding to the target view window in the loading information table, and determining initial address information and class name information of the target class to be loaded in the target class to be loaded. And determining a window address corresponding to the target view window. And calculating the offset of the address based on the initial address information and the window address corresponding to the target view window, determining target address information based on a calculation result, and storing the target address information and the class information as class loading information to a storage position.
Along the above example, the address corresponding to the target class to be loaded is determined, and the offset address is calculated through the global offset table (Global offset table) of the GOT table, so as to determine the class loading information corresponding to the target class to be loaded.
In summary, the target address information and the class information are stored as class loading information to the storage position, so that the class loading information of the target class to be loaded is accurately recorded in the loading information table, and the target class to be loaded is conveniently loaded again later.
Further, in the case that the loading of the target class to be loaded and the class to be loaded in the executable code file is completed, the dynamic loading of the class to be loaded in the executable code file is realized, and the specific implementation is as follows:
Under the condition that a page update request submitted by a target client is received, determining target class loading information corresponding to the page update request in the target storage space; and generating a data packet based on the target class loading information and feeding back to the target client.
Specifically, the page update request refers to a computer instruction for updating a currently displayed page of the client, where the update may be a page update or a page jump by clicking a function control in the currently displayed page; the target class loading information is information which corresponds to the page update request and is used for realizing page update or page display after page jump.
Based on the above, when a page update request submitted by a target client for a target page is received, class information corresponding to the page update request is determined, and target class loading information corresponding to the page update request is determined in a target storage space based on the class information. And generating a data packet based on the target class loading information, and feeding back to the target client for updating the target page or performing page jumping on the basis of the target page by the client.
Along the above example, when a user clicks a news control in a webpage, a page update request is submitted, class information corresponding to a news page is determined, target class loading information for generating the news page is determined in a target storage space based on information such as the name and the address of the class, and a data packet is generated and sent to a target client where the user is located to realize the display of the news page.
In summary, by generating the class loader corresponding to the class to be loaded based on the class loader information, determining the class loading view corresponding to the class loader, and establishing the mapping relationship between the class to be loaded and the view window in the class loading view, the association relationship among the class to be loaded, the class loader and the class loading view is constructed, so that the accuracy of class loading can be ensured on the basis of dynamic loading of the class when the class to be loaded is loaded subsequently. By constructing the association relation among the class to be loaded, the class loader and the class loading view, the code file to be executed can be compiled in advance in a dynamic class loading mode, and therefore the starting speed of the application program is improved.
The class loading method provided in the present specification is further described below by taking an application of the class loading method in dynamic class loading of a web page as an example in combination with fig. 5. Fig. 5 is a flowchart of a processing procedure of a loading method according to an embodiment of the present disclosure, which specifically includes the following steps.
In a practical application scenario, the requirement on the elastic capability of an application program is higher and higher, and one key factor affecting the elastic capability is the cold start speed. The speed of application cold start needs to be fast enough. For example, an online service system, the majority of the time has a low access, i.e., 10QPS. But perhaps for a certain period of time, the access volume will reach 100QPS, and in the case of a request volume increase from 10 to 100QPS within 1 minute, a new service needs to be created within 1 minute to cope with the increase in traffic, and if this application is cold started for 3 minutes, it is obviously impossible to complete the creation of the service within 1 minute. But if the application can complete the start-up within 30 seconds, then the surge in flow can be handled within 1 minute.
Java is widely used as a programming language at a server, and has long universal starting time and large occupied resources due to the dynamic class loading of Java, JIT and other reasons. The above problems can be overcome by compiling this technique in advance. By compiling the code into the code of the specific target machine in advance, interpretation and execution at start-up and JIT compiling are avoided, CPU overhead is reduced, and start-up speed is improved. The advanced compiling is a technology for reducing the memory and CPU overhead in the running process and improving the running performance of the program by compiling the code into the code of the target architecture. Advanced compilation is generally not able to support dynamic class loading, which results in the application not being able to use advanced compilation. Accordingly, there is a need for an effective method to solve the above-mentioned problems.
Step S502: and determining initial class loader information, class attribute information and class address information of the class code to be executed in the code file to be executed, and compiling the code file to be executed into a compiling file.
Under the conditions that a developer edits codes through a code editor and tests the codes, determining class metadata, namely class attribute information containing class name information and address information corresponding to the code position of the class according to the class codes in the codes to be executed. And determining class loader information such as memory identification of the class loader according to the code to be executed. And performing preliminary compiling on the code file to be executed, compiling the code file into a compiling file, wherein the compiling is a process of generating a target program from a source program written in a source language by utilizing a compiling program.
Step S504: class loading description information is generated based on the class attribute information and the class address information.
Step S506: at least two candidate class loader information is generated from the class loading description information and the initial class loader information.
And using the information such as class name information, code positions of the classes and the like as class loading description information. The class loader information is taken as initial class loader information. The class code sources are aggregated into class loader dimensions based on the class data, the class loader, and the code sources.
Step S508: selecting target class loader information from at least two candidate class loader information according to a preset selection rule, and taking the target class loader information as class loader information corresponding to class codes to be executed.
And determining class loading rules according to the class loading description information and the class loader information, and carrying out initial allocation of the class loading rules and package rule loading optimization.
Step S510: and deleting candidate class loader information except the target class loader information in the at least two candidate class loader information.
Deleting invalid null rules in the class loading rules, and distributing readable names for class loaders as class loader information of the class loaders. And establishing a relation between the code source and class loader information of the class loader, and realizing code source allocation and conflict resolution.
Step S512: a class loading description file is generated based on the class loading description information and the class loader information.
Step S514: and reading the class loading description information and the class loader information in the class loading description file.
Step S516: and determining class codes in the compiling file based on the class loading description information, compiling, and determining an executable code file containing the class to be loaded according to the compiling result.
And performing preliminary compiling on the code file to be executed to obtain a compiling file.
Step S518: and generating a class loader corresponding to the class to be loaded based on the class loader information, and determining a class loading view corresponding to the class loader.
Step S520: and establishing a mapping relation between the class to be loaded and a view window in the class loading view.
In practical application, when multiple people load classes at the same time, each person can correspond to one class loader because the class loader corresponding to each person is different. In the subsequent dynamic class loading process, the isolation function can be realized, and the generation of class loading errors and the influence on the unloading of the loaded classes are avoided.
Step S522: under the condition of calling a class loader and loading a target class to be loaded contained in an executable code file, determining a loading information table corresponding to the class loader; determining a storage position corresponding to the target view window in the loading information table; and determining class loading information corresponding to the target class to be loaded and storing the class loading information to a storage position corresponding to the target view window.
If the code compiled by the general AOT determines that any class is not loaded during running, the class is loaded, and class loading information is filled into a GOT table after loading is completed. And when the class is loaded again, repeated loading is not needed.
In order to support dynamic class loading, since it is not known in advance how many class loaders are, class loading views are dynamically created, each class loading view being in one-to-one correspondence with a class loader.
In summary, by generating the class loader corresponding to the class to be loaded based on the class loader information, determining the class loading view corresponding to the class loader, and establishing the mapping relationship between the class to be loaded and the view window in the class loading view, the association relationship among the class to be loaded, the class loader and the class loading view is constructed, so that the accuracy of class loading can be ensured on the basis of dynamic loading of the class when the class to be loaded is loaded subsequently. By constructing the association relation among the class to be loaded, the class loader and the class loading view, the code file to be executed can be compiled in advance in a dynamic class loading mode, and therefore the starting speed of the application program is improved.
Corresponding to the method embodiment, the present disclosure further provides a class loading device embodiment, and fig. 6 shows a schematic structural diagram of a class loading device provided in one embodiment of the present disclosure. As shown in fig. 6, the apparatus is applied to a server, and includes:
A determining module 602, configured to generate an executable code file containing a class to be loaded and a class loader corresponding to the class to be loaded according to initial class loading information, and determine a class loading view corresponding to the class loader;
a mapping relation establishing module 604, configured to establish a mapping relation between the class to be loaded and a view window in the class loading view;
the loading module 606 is configured to determine a target view window corresponding to the target class to be loaded based on the mapping relationship when the class loader is invoked and the target class to be loaded contained in the executable code file is loaded, and record class loading information of the target class to be loaded at a storage position corresponding to the target view window.
In an alternative embodiment, the first determining module 602 is further configured to:
determining the initial class loading information according to a code file to be executed, and compiling the code file to be executed into a compiling file; determining class codes in the compiling file based on the class loading description information in the initial class loading information, compiling, and determining an executable code file containing the class to be loaded according to a compiling result; generating a class loader corresponding to the class to be loaded based on the class loader information in the initial class loading information, and determining a class loading view corresponding to the class loader.
In an alternative embodiment, the first determining module 602 is further configured to:
generating a class loading description file based on the code file to be executed; and reading the class loading description information and the class loader information in the class loading description file, and taking the class loading description information and the class loader information as the initial class loading information.
In an alternative embodiment, the first determining module 602 is further configured to:
determining initial class loader information, class attribute information and class address information of class codes to be executed in a code file to be executed; generating class loading description information based on the class attribute information and the class address information; generating target class loader information according to the class loading description information and the initial class loader information, and taking the target class loader information as class loader information corresponding to the class code to be executed; and generating a class loading description file based on the class loading description information and the class loader information.
In an alternative embodiment, the first determining module 602 is further configured to:
generating at least two candidate class loader information according to the class loading description information and the initial class loader information; selecting target class loader information from at least two candidate class loader information according to a preset selection rule, and taking the target class loader information as class loader information corresponding to the class code to be executed.
In an alternative embodiment, the first determining module 602 is further configured to:
and deleting candidate class loader information except the target class loader information in the at least two candidate class loader information.
In an alternative embodiment, the first loading module 606 is further configured to:
and under the condition that the loading of the target class to be loaded is completed, generating executable class codes corresponding to the target class to be loaded and storing the executable class codes into a target storage space.
In an alternative embodiment, the first loading module 606 is further configured to:
determining a target view window corresponding to the target class to be loaded based on the mapping relation, and judging whether storage information exists in a storage position corresponding to the target view window; if yes, executing the step of generating executable class codes corresponding to the target class to be loaded and storing the executable class codes into a target storage space under the condition that the loading of the target class to be loaded is completed; and if not, executing the step of recording class loading information of the target class to be loaded at the storage position corresponding to the target view window.
In an alternative embodiment, the first loading module 606 is further configured to:
Determining a loading information table corresponding to the class loader; the recording the class loading information of the target class to be loaded at the storage position corresponding to the target view window comprises the following steps: determining a storage position corresponding to the target view window in the loading information table; determining initial address information and class information in the target class to be loaded, and determining target address information based on the initial address information and a window address corresponding to the target view window; and storing the target address information and the class information as the class loading information to the storage position.
In an alternative embodiment, the first determining module 602 is further configured to:
receiving an information acquisition request submitted by a client for a target task; analyzing the information acquisition request, determining target information corresponding to the target task according to an analysis result, and sending the target information serving as feedback of the information acquisition request to the client; and determining the code to be executed based on the target information, and executing the class loading description information and the class loader information determined according to the code file to be executed.
In an alternative embodiment, the first loading module 606 is further configured to:
Under the condition that a page update request submitted by a target client is received, determining target class loading information corresponding to the page update request in the target storage space; and generating a data packet based on the target class loading information and feeding back to the target client.
In summary, by generating the class loader corresponding to the class to be loaded based on the class loader information, determining the class loading view corresponding to the class loader, and establishing the mapping relationship between the class to be loaded and the view window in the class loading view, the association relationship among the class to be loaded, the class loader and the class loading view is constructed, so that the accuracy of class loading can be ensured on the basis of dynamic loading of the class when the class to be loaded is loaded subsequently. By constructing the association relation among the class to be loaded, the class loader and the class loading view, the code file to be executed can be compiled in advance in a dynamic class loading mode, and therefore the starting speed of the application program is improved.
The above is a schematic solution of a kind of loading device of the present embodiment. It should be noted that, the technical solution of the class loading device and the technical solution of the class loading method belong to the same concept, and details of the technical solution of the class loading device which are not described in detail can be referred to the description of the technical solution of the class loading method.
Corresponding to the method embodiment, the present disclosure further provides a class loading system embodiment, and fig. 7 shows a schematic structural diagram of a class loading system provided in one embodiment of the present disclosure. As shown in fig. 7, this type of loading system 700 includes: a client 710 and a server 720;
the server 720 determines a code file to be executed in response to a page information acquisition request submitted by the client 710 for an initial page; generating an executable code file containing a class to be loaded and a class loader corresponding to the class to be loaded according to the initial class loading information, and determining a class loading view corresponding to the class loader; establishing a mapping relation between the class to be loaded and a view window in the class loading view; under the condition that the class loader is called and a target class to be loaded contained in the executable code file is loaded, determining a target view window corresponding to the target class to be loaded based on the mapping relation, and recording class loading information of the target class to be loaded at a storage position corresponding to the target view window; under the condition that the loading of the target class to be loaded is completed, generating executable class codes corresponding to the target class to be loaded and storing the executable class codes into a target storage space; in the case of receiving the page update request submitted by the client, determining a target executable code corresponding to the page update request in the target storage space and feeding back to the client 710;
The client 710 updates the initial page based on the target executable code.
In practical application, when the application program is started, a page information acquisition request is submitted for an initial page containing the application program, and the page information acquisition request is used for starting the application program. And the server simultaneously acquires the code files to be executed corresponding to each functional module in the application program. The code file is compiled in advance and the class is dynamically loaded. And when the class loading is carried out, determining a code file to be executed, and determining class loading description information and class loader information according to the code file to be executed. Compiling the code file to be executed to obtain a compiled file, determining class codes in the compiled file based on the class loading description information, compiling, and determining the executable code file containing the class to be loaded according to the compiling result. And constructing a class loader corresponding to the class to be loaded based on the class loader information, and determining a class loading view corresponding to the class loader. And establishing a mapping relation between the class to be loaded and a view window in the class loading view.
And under the condition of calling a class loader and loading the target class to be loaded contained in the executable code file, determining a target view window corresponding to the target class to be loaded based on the mapping relation, and recording class loading information of the target class to be loaded in a storage position corresponding to the target view window. Under the condition that class codes needing to be loaded in the compiled codes are loaded, the advanced compiling is completed, and therefore the executing speed of subsequent tasks is improved. When the client side has the requirement of starting any function in the application program, submitting a page update request aiming at the function module, transmitting data with the client side through a protocol by a server in response to the page update request, and updating an interface by the client side.
By generating the class loader corresponding to the class to be loaded based on the class loader information, determining the class loading view corresponding to the class loader, and establishing the mapping relation between the class to be loaded and the view window in the class loading view, the association relation among the class to be loaded, the class loader and the class loading view is constructed, so that the accuracy of class loading can be ensured on the basis of dynamic loading of the class when the class to be loaded is loaded subsequently. By constructing the association relation among the class to be loaded, the class loader and the class loading view, the code file to be executed can be compiled in advance in a dynamic class loading mode, and therefore the starting speed of the application program is improved.
In summary, by determining the class loading view corresponding to the class loader and establishing the mapping relationship between the class to be loaded and the view window in the class loading view, the association relationship among the class to be loaded, the class loader and the class loading view is established, so that the accuracy of class loading can be ensured on the basis of dynamic loading of the class when the class to be loaded is loaded subsequently. By constructing the association relation among the class to be loaded, the class loader and the class loading view, the code file to be executed can be compiled in advance in a dynamic class loading mode, and therefore the starting speed of the application program is improved.
Fig. 8 illustrates a block diagram of a computing device 800 provided in accordance with one embodiment of the present description. The components of computing device 800 include, but are not limited to, memory 810 and processor 820. Processor 820 is coupled to memory 810 through bus 830 and database 850 is used to hold data.
Computing device 800 also includes access device 840, access device 840 enabling computing device 800 to communicate via one or more networks 860. Examples of such networks include public switched telephone networks (PSTN, public Switched Telephone Network), local area networks (LAN, local Area Network), wide area networks (WAN, wide Area Network), personal area networks (PAN, personal Area Network), or combinations of communication networks such as the internet. Access device 840 may include one or more of any type of network interface, wired or wireless, such as a network interface card (NIC, network interface controller), such as an IEEE802.11 wireless local area network (WLAN, wireless Local Area Network) wireless interface, a worldwide interoperability for microwave access (Wi-MAX, worldwide Interoperability for Microwave Access) interface, an ethernet interface, a universal serial bus (USB, universal Serial Bus) interface, a cellular network interface, a bluetooth interface, near field communication (NFC, near Field Communication).
In one embodiment of the present description, the above-described components of computing device 800, as well as other components not shown in FIG. 8, may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device illustrated in FIG. 8 is for exemplary purposes only and is not intended to limit the scope of the present description. Those skilled in the art may add or replace other components as desired.
Computing device 800 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), mobile phone (e.g., smart phone), wearable computing device (e.g., smart watch, smart glasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or personal computer (PC, personal Computer). Computing device 800 may also be a mobile or stationary server.
Wherein the processor 820 is configured to execute computer-executable instructions that, when executed by the processor, perform the steps of the class loading method described above.
The foregoing is a schematic illustration of a computing device of this embodiment. It should be noted that, the technical solution of the computing device and the technical solution of the class loading method belong to the same concept, and details of the technical solution of the computing device, which are not described in detail, can be referred to the description of the technical solution of the class loading method.
An embodiment of the present disclosure also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the class loading method described above.
The above is an exemplary version of a computer-readable storage medium of the present embodiment. It should be noted that, the technical solution of the storage medium and the technical solution of the class loading method belong to the same concept, and details of the technical solution of the storage medium which are not described in detail can be referred to the description of the technical solution of the class loading method.
An embodiment of the present disclosure also provides a computer program, where the computer program, when executed in a computer, causes the computer to perform the steps of the class loading method described above.
The above is an exemplary version of a computer program of the present embodiment. It should be noted that, the technical solution of the computer program and the technical solution of the class loading method belong to the same concept, and details of the technical solution of the computer program, which are not described in detail, can be referred to the description of the technical solution of the class loading method.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The computer instructions include computer program code that may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the content of the computer readable medium can be increased or decreased appropriately according to the requirements of the patent practice, for example, in some areas, according to the patent practice, the computer readable medium does not include an electric carrier signal and a telecommunication signal.
It should be noted that, for simplicity of description, the foregoing method embodiments are all expressed as a series of combinations of actions, but it should be understood by those skilled in the art that the embodiments are not limited by the order of actions described, as some steps may be performed in other order or simultaneously according to the embodiments of the present disclosure. Further, those skilled in the art will appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily all required for the embodiments described in the specification.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to the related descriptions of other embodiments.
The preferred embodiments of the present specification disclosed above are merely used to help clarify the present specification. Alternative embodiments are not intended to be exhaustive or to limit the invention to the precise form disclosed. Obviously, many modifications and variations are possible in light of the teaching of the embodiments. The embodiments were chosen and described in order to best explain the principles of the embodiments and the practical application, to thereby enable others skilled in the art to best understand and utilize the invention. This specification is to be limited only by the claims and the full scope and equivalents thereof.

Claims (14)

1. A kind loading method is applied to a server and comprises the following steps:
generating an executable code file containing a class to be loaded and a class loader corresponding to the class to be loaded according to initial class loading information, and determining a class loading view corresponding to the class loader, wherein the initial class loading information is determined based on class loading description information and class loader information; the class loading description information consists of class attribute information and class address information corresponding to class codes to be executed in a code file to be executed; the class loader information is generated by the class loading description information and initial class loader information corresponding to the class code to be executed in the code file to be executed;
establishing a mapping relation between the class to be loaded and a view window in the class loading view;
and under the condition that the class loader is called and the target class to be loaded contained in the executable code file is loaded, determining a target view window corresponding to the target class to be loaded based on the mapping relation, and recording class loading information of the target class to be loaded at a storage position corresponding to the target view window.
2. The method of claim 1, wherein generating, according to the initial class loading information, an executable code file including a class to be loaded and a class loader corresponding to the class to be loaded, and determining a class loading view corresponding to the class loader, includes:
Determining the initial class loading information according to a code file to be executed, and compiling the code file to be executed into a compiling file;
determining class codes in the compiling file based on the class loading description information in the initial class loading information, compiling, and determining an executable code file containing the class to be loaded according to a compiling result;
generating a class loader corresponding to the class to be loaded based on the class loader information in the initial class loading information, and determining a class loading view corresponding to the class loader.
3. The method of claim 2, the determining the initial class loading information from a code file to be executed, comprising:
generating a class loading description file based on the code file to be executed;
and reading the class loading description information and the class loader information in the class loading description file, and taking the class loading description information and the class loader information as the initial class loading information.
4. A method according to claim 3, said generating a class loading description file based on said code file to be executed comprising:
determining initial class loader information, class attribute information and class address information of class codes to be executed in a code file to be executed;
generating class loading description information based on the class attribute information and the class address information;
Generating target class loader information according to the class loading description information and the initial class loader information, and taking the target class loader information as class loader information corresponding to the class code to be executed;
and generating a class loading description file based on the class loading description information and the class loader information.
5. The method of claim 4, wherein the generating the target class loader information according to the class loading description information and the initial class loader information, and using the target class loader information as the class loader information corresponding to the class code to be executed, comprises:
generating at least two candidate class loader information according to the class loading description information and the initial class loader information;
selecting target class loader information from at least two candidate class loader information according to a preset selection rule, and taking the target class loader information as class loader information corresponding to the class code to be executed.
6. The method of claim 5, the method further comprising:
and deleting candidate class loader information except the target class loader information in the at least two candidate class loader information.
7. The method of claim 1, the method further comprising:
and under the condition that the loading of the target class to be loaded is completed, generating executable class codes corresponding to the target class to be loaded and storing the executable class codes into a target storage space.
8. The method of claim 7, wherein the determining, based on the mapping relationship, a target view window corresponding to the target class to be loaded, and recording class loading information of the target class to be loaded in a storage location corresponding to the target view window, includes:
determining a target view window corresponding to the target class to be loaded based on the mapping relation, and judging whether storage information exists in a storage position corresponding to the target view window;
if yes, executing the step of generating executable class codes corresponding to the target class to be loaded and storing the executable class codes into a target storage space under the condition that the loading of the target class to be loaded is completed;
and if not, executing the step of recording class loading information of the target class to be loaded at the storage position corresponding to the target view window.
9. The method of claim 1, further comprising, after the determining a class loading view corresponding to the class loader is performed:
Determining a loading information table corresponding to the class loader;
the recording the class loading information of the target class to be loaded at the storage position corresponding to the target view window comprises the following steps:
determining a storage position corresponding to the target view window in the loading information table;
determining initial address information and class information in the target class to be loaded, and determining target address information based on the initial address information and a window address corresponding to the target view window;
and storing the target address information and the class information as the class loading information to the storage position.
10. The method according to any one of claims 1-9, further comprising, before generating, according to the initial class loading information, an executable code file including a class to be loaded and a class loader corresponding to the class to be loaded:
receiving an information acquisition request submitted by a client for a target task;
analyzing the information acquisition request, determining target information corresponding to the target task according to an analysis result, and sending the target information serving as feedback of the information acquisition request to the client;
and determining the code to be executed based on the target information, and executing the class loading description information and the class loader information determined according to the code file to be executed.
11. The method of claim 7, after the step of generating the executable class code corresponding to the target class to be loaded and storing the executable class code in the target storage space is performed when the loading of the target class to be loaded is completed, further comprising:
under the condition that a page update request submitted by a target client is received, determining target class loading information corresponding to the page update request in the target storage space;
and generating a data packet based on the target class loading information and feeding back to the target client.
12. A class loading system, comprising a server and a client;
the server responds to a page information acquisition request submitted by the client for an initial page to determine a code file to be executed; generating an executable code file containing a class to be loaded and a class loader corresponding to the class to be loaded according to initial class loading information, and determining a class loading view corresponding to the class loader, wherein the initial class loading information is determined based on class loading description information and class loader information; the class loading description information consists of class attribute information and class address information corresponding to class codes to be executed in a code file to be executed; the class loader information is generated by the class loading description information and initial class loader information corresponding to the class code to be executed in the code file to be executed; establishing a mapping relation between the class to be loaded and a view window in the class loading view; under the condition that the class loader is called and a target class to be loaded contained in the executable code file is loaded, determining a target view window corresponding to the target class to be loaded based on the mapping relation, and recording class loading information of the target class to be loaded at a storage position corresponding to the target view window; under the condition that the loading of the target class to be loaded is completed, generating executable class codes corresponding to the target class to be loaded and storing the executable class codes into a target storage space; under the condition that a page update request submitted by the client is received, determining a target executable code corresponding to the page update request in the target storage space and feeding back to the client;
And the client updates the initial page based on the target executable code.
13. A computing device, comprising:
a memory and a processor;
the memory is configured to store computer executable instructions, the processor being configured to execute the computer executable instructions, which when executed by the processor, implement the steps of the method of any one of claims 1 to 11.
14. A computer readable storage medium storing computer executable instructions which when executed by a processor implement the steps of the method of any one of claims 1 to 11.
CN202311228738.9A 2023-09-21 2023-09-21 Class loading method and system Active CN116974653B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311228738.9A CN116974653B (en) 2023-09-21 2023-09-21 Class loading method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311228738.9A CN116974653B (en) 2023-09-21 2023-09-21 Class loading method and system

Publications (2)

Publication Number Publication Date
CN116974653A CN116974653A (en) 2023-10-31
CN116974653B true CN116974653B (en) 2024-01-09

Family

ID=88473399

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311228738.9A Active CN116974653B (en) 2023-09-21 2023-09-21 Class loading method and system

Country Status (1)

Country Link
CN (1) CN116974653B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110750315A (en) * 2019-12-23 2020-02-04 武汉斗鱼鱼乐网络科技有限公司 Class loading method, device, equipment and storage medium in Android system
CN111324359A (en) * 2020-02-27 2020-06-23 支付宝(杭州)信息技术有限公司 Plug-in deployment method and device
CN111736913A (en) * 2019-03-25 2020-10-02 华为技术有限公司 Class loading method and device
CN112364275A (en) * 2020-11-10 2021-02-12 平安普惠企业管理有限公司 Page loading method, device, equipment and storage medium
CN114253587A (en) * 2021-12-17 2022-03-29 中电金信软件有限公司 Application program updating method and device, electronic equipment and readable storage medium
CN115576560A (en) * 2022-09-22 2023-01-06 摩尔元数(福建)科技有限公司 Hot reloading method, device, equipment and medium for dynamic loader
CN116594717A (en) * 2023-05-24 2023-08-15 上海汉朔信息科技有限公司 Class loading isolation method, device, equipment and medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9286085B2 (en) * 2014-06-27 2016-03-15 International Business Machines Corporation Correlating class loader objects across execution environments

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111736913A (en) * 2019-03-25 2020-10-02 华为技术有限公司 Class loading method and device
CN114153521A (en) * 2019-03-25 2022-03-08 华为技术有限公司 Class loading method and device
CN110750315A (en) * 2019-12-23 2020-02-04 武汉斗鱼鱼乐网络科技有限公司 Class loading method, device, equipment and storage medium in Android system
CN111324359A (en) * 2020-02-27 2020-06-23 支付宝(杭州)信息技术有限公司 Plug-in deployment method and device
CN112364275A (en) * 2020-11-10 2021-02-12 平安普惠企业管理有限公司 Page loading method, device, equipment and storage medium
CN114253587A (en) * 2021-12-17 2022-03-29 中电金信软件有限公司 Application program updating method and device, electronic equipment and readable storage medium
CN115576560A (en) * 2022-09-22 2023-01-06 摩尔元数(福建)科技有限公司 Hot reloading method, device, equipment and medium for dynamic loader
CN116594717A (en) * 2023-05-24 2023-08-15 上海汉朔信息科技有限公司 Class loading isolation method, device, equipment and medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Accurate Reification of Complete Supertype Information for Dynamic Analysis on the JVM;Rosa, Andrea等;《ACM SIGPLAN NOTICES》;第52卷;全文 *
Java动态类加载机制应用研究;孙彬;;科技创新与应用(第23期);全文 *
Java动态类加载机制研究及应用;黄军;《信息与电脑(理论版)》(4);全文 *

Also Published As

Publication number Publication date
CN116974653A (en) 2023-10-31

Similar Documents

Publication Publication Date Title
EP3876116B1 (en) Method and apparatus for running mini program, electronic device, and storage medium
CN106648755B (en) Method and device for dynamically loading dex in android art environment
CN109240697B (en) Call processing method and device and storage medium
WO2015131804A1 (en) Call stack relationship acquiring method and apparatus
CN107729014B (en) Page jump method and structure based on Android
CN110365724B (en) Task processing method and device and electronic equipment
KR20110052521A (en) Information-processing device, communication system, computer readable medium, and information-processing method
CN110858172A (en) Automatic test code generation method and device
CN112817657B (en) Application program starting item loading method, device, system and storage medium
CN110895471A (en) Installation package generation method, device, medium and electronic equipment
CN111857881A (en) Repo-based manifest warehouse loading method and device and storage medium
CN116974653B (en) Class loading method and system
CN111488286B (en) Method and device for independently developing Android modules
CN111427770B (en) Resource testing method and related equipment
CN111400623B (en) Method and device for searching information
CN115016775A (en) Interface simulation method and device, storage medium and electronic equipment
CN115048082A (en) Micro front-end system construction method and device, server and readable storage medium
CN114489603A (en) Code generation method, apparatus, electronic device, medium, and product
CN110471708B (en) Method and device for acquiring configuration items based on reusable components
CN113495723A (en) Method and device for calling functional component and storage medium
CN106570143B (en) Method and device for sending response object
CN111966506A (en) Content sharing method based on different application programs and computer equipment
CN111026466A (en) File processing method and device, computer readable storage medium and electronic equipment
CN112306649B (en) Method and device for managing processes
US20230385075A1 (en) Networked Universal Code Package Provider

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant