CN116302349A - Method for accelerating Java application program starting speed and related components thereof - Google Patents

Method for accelerating Java application program starting speed and related components thereof Download PDF

Info

Publication number
CN116302349A
CN116302349A CN202310266692.3A CN202310266692A CN116302349A CN 116302349 A CN116302349 A CN 116302349A CN 202310266692 A CN202310266692 A CN 202310266692A CN 116302349 A CN116302349 A CN 116302349A
Authority
CN
China
Prior art keywords
class
target class
file
target
loader
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.)
Pending
Application number
CN202310266692.3A
Other languages
Chinese (zh)
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.)
Southern Power Grid Digital Grid Research Institute Co Ltd
Original Assignee
Southern Power Grid Digital Grid Research Institute Co 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 Southern Power Grid Digital Grid Research Institute Co Ltd filed Critical Southern Power Grid Digital Grid Research Institute Co Ltd
Priority to CN202310266692.3A priority Critical patent/CN116302349A/en
Publication of CN116302349A publication Critical patent/CN116302349A/en
Pending legal-status Critical Current

Links

Images

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/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • 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
    • 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/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • 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/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances
    • 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 application discloses a method for accelerating the starting speed of a Java application program and related components thereof, which are applied to a Java virtual machine, and relate to the technical field of computers, and comprise the following steps: loading and analyzing a target class file acquired from a disk by using a target class loader to generate a klass object; the target class loader is any one of a guide class loader, an extension class loader and an application program class loader; if the klass object can be shared, writing the full-limit name of the klass object into a preset sharing list; reading a preset sharing list, and loading a corresponding class file so as to write corresponding class data into a preset archive file; mapping a preset archive file into a memory in the starting process of a java application program, so that target class data corresponding to class loading operation is obtained from the memory after the class loading operation is triggered, and a system dictionary is updated by using the target class data. The class sharing range of CDS characteristics is enlarged, and the starting speed of the application program is improved.

Description

Method for accelerating Java application program starting speed and related components thereof
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for accelerating a Java application program start speed.
Background
Under the trend that the volume of the current application program is larger and larger, the service scene of the application program is complex, rich service functions are included, the deployment package depends on more third-party technologies and service components, and the volume is larger. In the starting process of the application program, a large number of third-party dependencies need to be traversed and searched to complete the class loading process, and the class loading process is long due to the fact that the number of the dependencies JAR (Java Archive File) is large, so that the starting time of the application program is long, and the starting time of the application program needs to be shortened. When a certain class is needed by the JVM (Java Virtual Machine, i.e., the Java virtual machine), the JVM finds the class file from the disk, loads the class file, verifies the bytecode file, prepares, parses, initializes, and loads the class file into the memory according to the internal data structure thereof, and the class can be used. For packed JAR packets, the data of the class in the JAR packet is always the same as long as the content of the JAR packet is unchanged. The JVM runs the same loading step each time it is started, consuming a lot of time. JDK has performed related work on how to shorten the startup time of an application, introducing CDS (Class-Data Sharing) features.
The CDS characteristic of the JDK is that the JVM only performs loading, linking and initializing actions once, and then class data is dumped into a file. When a certain class needs to be loaded after the JVM is started, the JVM searches the needed class from a dumped file, and the needed class data in the dumped file is loaded into a JVM memory if the re-execution class loading process is not found. However, current CDS technology only supports classes loaded by Bootstrap Classloader (boot class loader) and Ext Classloader (extended class loader), with limited application launch speed boost.
In summary, how to further increase the starting speed of the application is a problem to be solved at present.
Disclosure of Invention
Accordingly, the present invention is directed to a method, apparatus, device and medium for accelerating the starting speed of a Java application, which can further accelerate the starting speed of the application. The specific scheme is as follows:
in a first aspect, the present application discloses a method for accelerating a starting speed of a Java application, which is applied to a Java virtual machine, and includes:
obtaining a target class file from a disk, and loading and analyzing the target class file by using a target class loader to generate a corresponding klass object; the target class loader is any one kind of loader among a guide class loader, an extension class loader and an application program class loader;
judging whether the klass object can be shared, if so, writing the full-limit name of the target class file into a preset sharing list;
reading the preset sharing list, and loading class files corresponding to each full-limit name so as to write corresponding class data into preset archive files;
and mapping the preset archive file into a memory in the starting process of the java application program, so that after class loading operation is triggered, target class data corresponding to the class loading operation is obtained from the memory, and a system dictionary is updated by using the target class data.
Optionally, the loading and parsing the target class file by using a target class loader to generate a corresponding klass object includes:
and determining a corresponding target class loader based on the directory information and the path information of the target class file so as to load and analyze the target class file by using the target class loader to generate a corresponding klass object.
Optionally, the determining whether the klass object can be shared includes:
and judging whether the klass object can be shared or not based on the sharing class of the system dictionary.
Optionally, after the determining whether the klass object can be shared, the method further includes:
if not, judging that the full-limit name of the target class file cannot be written into a preset sharing list.
Optionally, the reading the preset sharing list, and loading a class file corresponding to each full-defined name, so as to write corresponding class data into a preset archive file, including:
and reading the full-limit names in the preset sharing list, loading class files corresponding to each full-limit name until all the class files are loaded, and writing corresponding class data into preset archive files.
Optionally, the obtaining the target class data corresponding to the class loading operation from the memory, and updating the system dictionary with the target class data includes:
determining a target class object corresponding to the class loading operation, and judging whether target class data corresponding to the target class object exists in the memory or not;
if so, acquiring the target class data from the memory, and updating a system dictionary by using the target class data.
Optionally, after the determining whether the memory has the target class data corresponding to the target klass object, the method further includes:
if not, taking the class file corresponding to the class loading operation as a target class file;
and re-jumping to the step of acquiring the target class file from the disk, loading and analyzing the target class file by using a target class loader to generate a corresponding klass object until target class data corresponding to the class loading operation is acquired from the memory, and updating a system dictionary by using the target class data.
In a second aspect, the present application discloses a device for accelerating a starting speed of a Java application, which is applied to a Java virtual machine, and includes:
the file loading module is used for acquiring a target class file from the disk, and loading and analyzing the target class file by utilizing a target class loader to generate a corresponding klass object; the target class loader is any one kind of loader among a guide class loader, an extension class loader and an application program class loader;
the judging module is used for judging whether the klass object can be shared or not, if so, writing the full-limit name of the target class file into a preset sharing list;
the archive file writing module is used for reading the preset sharing list, and loading class files corresponding to each full-limit name so as to write corresponding class data into the preset archive file;
the mapping module is used for mapping the preset archive file into a memory in the starting process of the java application program so as to acquire target class data corresponding to class loading operation from the memory after class loading operation is triggered, and updating a system dictionary by utilizing the target class data.
In a third aspect, the present application discloses an electronic device comprising:
a memory for storing a computer program;
and the processor is used for executing the computer program to realize the steps of the method for accelerating the starting speed of the Java application program.
In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program when executed by the processor implements the steps of the method for accelerating the starting speed of the Java application disclosed above.
Therefore, the target class file is obtained from the disk through the Java virtual machine, and the target class file is loaded and analyzed by the target class loader to generate a corresponding klass object; the target class loader is any one kind of loader among a guide class loader, an extension class loader and an application program class loader; judging whether the klass object can be shared, if so, writing the full-limit name of the target class file into a preset sharing list; reading the preset sharing list, and loading class files corresponding to each full-limit name so as to write corresponding class data into preset archive files; and mapping the preset archive file into a memory in the starting process of the java application program, so that after class loading operation is triggered, target class data corresponding to the class loading operation is obtained from the memory, and a system dictionary is updated by using the target class data. Therefore, the application also increases the class loaded by the application program class loader on the basis of supporting the class loaded by the boot class loader and the extension class loader, enlarges the class sharing range of CDS characteristics, greatly promotes the class which can be dumped, and remarkably promotes the starting speed of the application program. And after the Java virtual machine acquires the target class file from the disk, recording and analyzing the target class file by using a corresponding target class loader so as to dump the corresponding class data into a preset archive file, mapping the preset archive file into a memory directly in the starting process of the Java application program, acquiring target class data corresponding to the current class loading operation from the memory, and updating a system dictionary by using the target class data. The process does not need to reload the class file to acquire the corresponding class data, reduces class loading steps, shortens the starting time of the application program, and improves the starting speed of the application program.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings may be obtained according to the provided drawings without inventive effort to a person skilled in the art.
FIG. 1 is a flowchart of a method for accelerating the starting speed of a Java application program;
FIG. 2 is a schematic flow chart for accelerating the starting speed of a Java application program;
FIG. 3 is a flow chart of one of the generation lst files disclosed herein;
FIG. 4 is a flowchart of a specific method for accelerating the starting speed of a Java application;
FIG. 5 is a flow chart of generating jsa archive files as disclosed herein;
FIG. 6 is a flow chart of archiving files using jsa as disclosed herein;
FIG. 7 is a schematic diagram of a device for accelerating the starting speed of a Java application;
fig. 8 is a block diagram of an electronic device disclosed in the present application.
Detailed Description
The following description of the technical solutions in the embodiments of the present application will be made clearly and completely with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The CDS characteristic of the JDK is that the JVM only performs loading, linking and initializing actions once, and then class data is dumped into a file. When a certain class needs to be loaded after the JVM is started, the JVM searches the needed class from a dumped file, and the needed class data in the dumped file is loaded into a JVM memory if the re-execution class loading process is not found. However, current CDS technology only supports classes loaded by Bootstrap Classloader (boot class loader) and Ext Classloader (extended class loader), with limited application launch speed boost. Therefore, the embodiment of the application discloses a method, a device, equipment and a medium for accelerating the starting speed of a Java application program, which can further improve the starting speed of the application program.
Referring to fig. 1 and fig. 2, an embodiment of the present application discloses a method for accelerating a Java application program start-up speed, applied to a Java virtual machine, the method includes:
step S11: obtaining a target class file from a disk, and loading and analyzing the target class file by using a target class loader to generate a corresponding klass object; the target class loader is any one kind of loader among a boot class loader, an extension class loader and an application program class loader.
In this embodiment, when the Java virtual machine needs to use a certain class, the Java virtual machine finds and obtains the target class file from the disk, and generates a corresponding klass object after loading and analyzing by the target class loader. As shown in fig. 3, the target class loader is any one of a boot class loader, an extension class loader, and an application class loader. That is, the application increases the class loaded by the application program class loader on the basis of supporting the class loaded by the boot class loader and the extension class loader, enlarges the class sharing range of CDS characteristics, greatly promotes the class which can be dumped, and remarkably promotes the starting speed of the application program.
Step S12: and judging whether the klass object can be shared, if so, writing the full-limit name of the target class file into a preset sharing list.
In this embodiment, when determining whether the klass object can be shared, the method specifically includes: and judging whether the klass object can be shared or not based on the sharing class of the system dictionary. That is, in this embodiment, whether the klass object can be shared is determined by the sharing class of the system dictionary, and if the klass object can be shared, the full-defined name of the target class file is written into a preset sharing list, where the preset sharing list is specifically lst file. That is, through the scheme described above, the sharable class may be written to the lst file to generate the lst file.
Further, after the determining whether the klass object can be shared, the method further includes: if not, judging that the full-limit name of the target class file cannot be written into a preset sharing list. That is, if the klass object cannot be shared, it is determined that the full-defined name of the target class file cannot be written into the preset sharing list, that is, the dumping cannot be performed.
Step S13: and reading the preset sharing list, and loading class files corresponding to each full-limit name so as to write corresponding class data into preset archive files.
In this embodiment, the Java virtual machine reads the preset sharing list, that is, reads the content in the lst file, and then loads the class file corresponding to each full defined name. After the class is loaded, a system dictionary (SystemDictionary) is updated, and the Java virtual machine writes the corresponding data into the memory, and then the data dump is written into a preset archive file, wherein the preset archive file is specifically jsa archive file. That is, by the above scheme, the class data recorded in the lst file can be recorded in the jsa archive file, and the jsa archive file can be generated.
Step S14: and mapping the preset archive file into a memory in the starting process of the java application program, so that after class loading operation is triggered, target class data corresponding to the class loading operation is obtained from the memory, and a system dictionary is updated by using the target class data.
In this embodiment, during the starting process of the Java application program, the Java virtual machine maps jsa archive files to the memory. After the class loading operation is triggered, the Java virtual machine firstly acquires target class data corresponding to the class loading operation from the memory mapped in by the Java virtual machine, and after the target class data is acquired, the Java virtual machine updates a system dictionary by utilizing the target class data. The process does not need to reload the class file to acquire the corresponding class data, reduces class loading steps, shortens the starting time of the application program, and improves the starting speed of the application program.
Therefore, the target class file is obtained from the disk through the Java virtual machine, and the target class file is loaded and analyzed by the target class loader to generate a corresponding klass object; the target class loader is any one kind of loader among a guide class loader, an extension class loader and an application program class loader; judging whether the klass object can be shared, if so, writing the full-limit name of the target class file into a preset sharing list; reading the preset sharing list, and loading class files corresponding to each full-limit name so as to write corresponding class data into preset archive files; and mapping the preset archive file into a memory in the starting process of the java application program, so that after class loading operation is triggered, target class data corresponding to the class loading operation is obtained from the memory, and a system dictionary is updated by using the target class data. Therefore, the application also increases the class loaded by the application program class loader on the basis of supporting the class loaded by the boot class loader and the extension class loader, enlarges the class sharing range of CDS characteristics, greatly promotes the class which can be dumped, and remarkably promotes the starting speed of the application program. And after the Java virtual machine acquires the target class file from the disk, recording and analyzing the target class file by using a corresponding target class loader so as to dump the corresponding class data into a preset archive file, mapping the preset archive file into a memory directly in the starting process of the Java application program, acquiring target class data corresponding to the current class loading operation from the memory, and updating a system dictionary by using the target class data. The process does not need to reload the class file to acquire the corresponding class data, reduces class loading steps, shortens the starting time of the application program, and improves the starting speed of the application program.
Referring to fig. 4, an embodiment of the present application discloses a specific method for accelerating the starting speed of a Java application, and compared with the previous embodiment, the present embodiment further describes and optimizes a technical solution. The method specifically comprises the following steps:
step S21: acquiring a target class file from a disk, and determining a corresponding target class loader based on directory information and path information of the target class file so as to load and analyze the target class file by using the target class loader to generate a corresponding klass object; the target class loader is any one kind of loader among a boot class loader, an extension class loader and an application program class loader.
In this embodiment, the corresponding target class loader is determined based on the directory information and the path information of the target class file. For example, the boot class loader is responsible for loading the jar packets and classes under the%JAVA_HOME%/lib directory or all classes in the path specified by the-Xbaootclaspath parameter; the extension class loader is mainly responsible for loading jar packets and classes under the%JRE_HOME%/lib/ext directory or jar packets under the path specified by the java. Ext. Dirs system variable; the application class loader is a user-oriented loader and is responsible for loading all jar packages and classes under the current application classpath.
Step S22: and judging whether the klass object can be shared, if so, writing the full-limit name of the target class file into a preset sharing list.
Step S23: and reading the full-limit names in the preset sharing list, loading class files corresponding to each full-limit name until all the class files are loaded, and writing corresponding class data into preset archive files.
In this embodiment, referring to fig. 5, the Java virtual machine reads the content in the lst file, and then loads the corresponding class. The class is loaded to update the system dictionary, and when all corresponding class files in the lst file are loaded, the Java virtual machine writes the corresponding class data into the jsa archive file.
Step S24: mapping the preset archive file into a memory in the starting process of the java application program, so as to determine a target class object corresponding to the class loading operation after the class loading operation is triggered, and judging whether target class data corresponding to the target class object exists in the memory.
In this embodiment, referring to fig. 6, a preset archive file is mapped to a memory during the starting process of a java application. After the class loading operation is triggered, firstly determining a target class object corresponding to the class loading operation, and then judging whether target class data corresponding to the target class object exists in the memory or not, namely judging whether the target class data corresponding to the target class object can be acquired from the memory or not.
Step S25: if so, acquiring the target class data from the memory, and updating a system dictionary by using the target class data.
In this embodiment, if there is target class data corresponding to the target klass object in the memory, the target class data is directly obtained from the memory, and the system dictionary is updated by using the target class data. That is, in this embodiment, the class data is mapped to the memory by the archive file without reloading the class file to obtain the corresponding class data, so that class loading steps are reduced, the starting time of the application program is shortened, and the starting speed of the application program is improved.
In addition, after determining whether the target class data corresponding to the target klass object exists in the memory, the method further includes: if not, taking the class file corresponding to the class loading operation as a target class file; and re-jumping to the step of acquiring the target class file from the disk, loading and analyzing the target class file by using a target class loader to generate a corresponding klass object until target class data corresponding to the class loading operation is acquired from the memory, and updating a system dictionary by using the target class data. That is, if the corresponding target class data does not exist in the memory, then the normal class loading process, that is, parsing, linking, initializing, etc., is executed. And the class file corresponding to the class loading operation is used as a target class file, then the target class file is obtained from the disk, the target class loader is used for loading and analyzing the target class file to generate a corresponding klass object, until the target class data corresponding to the class loading operation is obtained from the memory, and then the target class data is used for updating the system dictionary.
For more specific processing in step S22, reference may be made to the corresponding content disclosed in the foregoing embodiment, and no further description is given here.
Therefore, after the target class file is obtained, the corresponding target class loader is determined according to the directory information and the path information, and then the target class loader is used for loading and analyzing the target class file. The target class loader comprises a boot class loader and an extension class loader, and also comprises an application program class loader, so that the class sharing range of CDS characteristics is enlarged, the class which can be dumped is greatly promoted, and the starting speed of the application program is remarkably promoted. In addition, after the class data is written into the archive file, the archive file is mapped into the memory in the starting process of the java application program, so that after the class loading operation is triggered, if the target class data corresponding to the target klass object exists in the memory, the class data can be directly obtained from the memory, the class file is not required to be reloaded to obtain the corresponding class data, class loading steps are reduced, the starting time of the application program is shortened, and the starting speed of the application program is improved. And if the target class data does not exist in the memory, executing the normal class loading flow.
Referring to fig. 7, an embodiment of the present application discloses a device for accelerating the starting speed of a Java application, which includes:
the file loading module 11 is used for acquiring a target class file from a disk, and loading and analyzing the target class file by utilizing a target class loader to generate a corresponding klass object; the target class loader is any one kind of loader among a guide class loader, an extension class loader and an application program class loader;
the judging module 12 is configured to judge whether the klass object can be shared, if yes, write the full-defined name of the target class file into a preset sharing list;
an archive file writing module 13, configured to read the preset sharing list, and load class files corresponding to each of the full-defined names, so as to write corresponding class data into a preset archive file;
the mapping module 14 is configured to map the preset archive file to a memory during a java application program starting process, so that after a class loading operation is triggered, target class data corresponding to the class loading operation is obtained from the memory, and a system dictionary is updated by using the target class data.
Therefore, the target class file is obtained from the disk through the Java virtual machine, and the target class file is loaded and analyzed by the target class loader to generate a corresponding klass object; the target class loader is any one kind of loader among a guide class loader, an extension class loader and an application program class loader; judging whether the klass object can be shared, if so, writing the full-limit name of the target class file into a preset sharing list; reading the preset sharing list, and loading class files corresponding to each full-limit name so as to write corresponding class data into preset archive files; and mapping the preset archive file into a memory in the starting process of the java application program, so that after class loading operation is triggered, target class data corresponding to the class loading operation is obtained from the memory, and a system dictionary is updated by using the target class data. Therefore, the application also increases the class loaded by the application program class loader on the basis of supporting the class loaded by the boot class loader and the extension class loader, enlarges the class sharing range of CDS characteristics, greatly promotes the class which can be dumped, and remarkably promotes the starting speed of the application program. And after the Java virtual machine acquires the target class file from the disk, recording and analyzing the target class file by using a corresponding target class loader so as to dump the corresponding class data into a preset archive file, mapping the preset archive file into a memory directly in the starting process of the Java application program, acquiring target class data corresponding to the current class loading operation from the memory, and updating a system dictionary by using the target class data. The process does not need to reload the class file to acquire the corresponding class data, reduces class loading steps, shortens the starting time of the application program, and improves the starting speed of the application program.
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Specifically, the method comprises the following steps: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. The memory 22 is configured to store a computer program, where the computer program is loaded and executed by the processor 21, so as to implement relevant steps in the method for accelerating the start speed of a Java application, which is executed by the electronic device and disclosed in any of the foregoing embodiments.
In this embodiment, the power supply 23 is configured to provide an operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and the communication protocol to be followed is any communication protocol applicable to the technical solution of the present application, which is not specifically limited herein; the input/output interface 25 is used for acquiring external input data or outputting external output data, and the specific interface type thereof may be selected according to the specific application requirement, which is not limited herein.
Processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 may be implemented in at least one hardware form of DSP (Digital Signal Processing ), FPGA (Field-Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array ). The processor 21 may also comprise a main processor, which is a processor for processing data in an awake state, also called CPU (Central Processing Unit ); a coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit, image processor) for rendering and drawing of content required to be displayed by the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence ) processor for processing computing operations related to machine learning.
The memory 22 may be a carrier for storing resources, such as a read-only memory, a random access memory, a magnetic disk, or an optical disk, and the resources stored thereon include an operating system 221, a computer program 222, and data 223, and the storage may be temporary storage or permanent storage.
The operating system 221 is used for managing and controlling various hardware devices on the electronic device 20 and the computer program 222, so as to implement the operation and processing of the processor 21 on the mass data 223 in the memory 22, which may be Windows, unix, linux. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the method of accelerating the start of a Java application performed by the electronic device 20 as disclosed in any of the previous embodiments. The data 223 may include, in addition to data received by the electronic device and transmitted by the external device, data collected by the input/output interface 25 itself, and so on.
Further, the embodiment of the application also discloses a computer readable storage medium, wherein the storage medium stores a computer program, and when the computer program is loaded and executed by a processor, the method steps executed in the process of accelerating the starting speed of the Java application program disclosed in any embodiment are realized.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The method, the device, the equipment and the storage medium for accelerating the starting speed of the Java application program provided by the invention are described in detail, and specific examples are applied to the principle and the implementation mode of the invention, and the description of the above examples is only used for helping to understand the method and the core idea of the invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (10)

1. A method for accelerating the starting speed of Java application programs is characterized by being applied to a Java virtual machine and comprising the following steps:
obtaining a target class file from a disk, and loading and analyzing the target class file by using a target class loader to generate a corresponding klass object; the target class loader is any one kind of loader among a guide class loader, an extension class loader and an application program class loader;
judging whether the klass object can be shared, if so, writing the full-limit name of the target class file into a preset sharing list;
reading the preset sharing list, and loading class files corresponding to each full-limit name so as to write corresponding class data into preset archive files;
and mapping the preset archive file into a memory in the starting process of the java application program, so that after class loading operation is triggered, target class data corresponding to the class loading operation is obtained from the memory, and a system dictionary is updated by using the target class data.
2. The method for accelerating the start-up of a Java application according to claim 1, wherein said loading and parsing the object class file with the object class loader to generate the corresponding klass object comprises:
and determining a corresponding target class loader based on the directory information and the path information of the target class file so as to load and analyze the target class file by using the target class loader to generate a corresponding klass object.
3. The method for accelerating the start-up of a Java application according to claim 1, wherein said determining whether said klass object can be shared comprises:
and judging whether the klass object can be shared or not based on the sharing class of the system dictionary.
4. The method for accelerating the start-up of a Java application according to claim 1, further comprising, after said determining whether said klass object can be shared:
if not, judging that the full-limit name of the target class file cannot be written into a preset sharing list.
5. The method for accelerating the start-up speed of a Java application according to claim 1, wherein the reading the preset sharing list and loading the class file corresponding to each of the fully qualified names so as to write the corresponding class data into the preset archive file comprises:
and reading the full-limit names in the preset sharing list, loading class files corresponding to each full-limit name until all the class files are loaded, and writing corresponding class data into preset archive files.
6. The method for accelerating the start-up speed of a Java application according to any one of claims 1 to 5, wherein the obtaining the target class data corresponding to the class loading operation from the memory and updating the system dictionary using the target class data comprises:
determining a target class object corresponding to the class loading operation, and judging whether target class data corresponding to the target class object exists in the memory or not;
if so, acquiring the target class data from the memory, and updating a system dictionary by using the target class data.
7. The method for accelerating the start-up speed of a Java application according to claim 6, further comprising, after determining whether there is target class data corresponding to the target klass object in the memory:
if not, taking the class file corresponding to the class loading operation as a target class file;
and re-jumping to the step of acquiring the target class file from the disk, loading and analyzing the target class file by using a target class loader to generate a corresponding klass object until target class data corresponding to the class loading operation is acquired from the memory, and updating a system dictionary by using the target class data.
8. An apparatus for accelerating the starting speed of a Java application, which is applied to a Java virtual machine, comprising:
the file loading module is used for acquiring a target class file from the disk, and loading and analyzing the target class file by utilizing a target class loader to generate a corresponding klass object; the target class loader is any one kind of loader among a guide class loader, an extension class loader and an application program class loader;
the judging module is used for judging whether the klass object can be shared or not, if so, writing the full-limit name of the target class file into a preset sharing list;
the archive file writing module is used for reading the preset sharing list, and loading class files corresponding to each full-limit name so as to write corresponding class data into the preset archive file;
the mapping module is used for mapping the preset archive file into a memory in the starting process of the java application program so as to acquire target class data corresponding to class loading operation from the memory after class loading operation is triggered, and updating a system dictionary by utilizing the target class data.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the method for accelerating the start-up speed of a Java application according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program; wherein the computer program when executed by a processor implements the steps of a method of accelerating the start-up of a Java application according to any of claims 1 to 7.
CN202310266692.3A 2023-03-17 2023-03-17 Method for accelerating Java application program starting speed and related components thereof Pending CN116302349A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310266692.3A CN116302349A (en) 2023-03-17 2023-03-17 Method for accelerating Java application program starting speed and related components thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310266692.3A CN116302349A (en) 2023-03-17 2023-03-17 Method for accelerating Java application program starting speed and related components thereof

Publications (1)

Publication Number Publication Date
CN116302349A true CN116302349A (en) 2023-06-23

Family

ID=86826888

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310266692.3A Pending CN116302349A (en) 2023-03-17 2023-03-17 Method for accelerating Java application program starting speed and related components thereof

Country Status (1)

Country Link
CN (1) CN116302349A (en)

Similar Documents

Publication Publication Date Title
KR100864192B1 (en) Method and device for creating and using pre-internalized program files
US6272674B1 (en) Method and apparatus for loading a Java application program
US20100205604A1 (en) Systems and methods for efficiently running multiple instances of multiple applications
JP2005182809A (en) Creating file system within file in storage technology-abstracted manner
EP3035191A1 (en) Identifying source code used to build executable files
US6633892B1 (en) Archiving tool
US20120266149A1 (en) Class isolation to minimize memory usage in a device
KR20150070121A (en) Layout and execution of software applications using bpram
WO2021164367A1 (en) Container mirror image providing method, container mirror image loading method, and related device and system
KR20150052107A (en) Layout and execution of operating systems using bpram
US8423994B2 (en) Recipe based application conversion
CN110515647A (en) A kind of static resource management method, device, equipment and storage medium
EP2511820A1 (en) Bypassing user mode redirection
CN115269025A (en) Kernel quick starting method and device, electronic equipment and storage medium
JP4280749B2 (en) Log acquisition method, program, and storage medium
CN112235132B (en) Method, device, medium and server for dynamically configuring service
US9244672B2 (en) Optimization utility for developing embedded systems
CN106909353B (en) Application program running method and device
CN116302349A (en) Method for accelerating Java application program starting speed and related components thereof
CN116069366A (en) Client application program updating method and device, storage medium and electronic equipment
KR101140522B1 (en) System and Method for Managing Object
WO2019157891A1 (en) Application installation method and application installer generating method
CN113924548A (en) Automatic hydration of a signature batch
CN106959870B (en) Nginx dynamic module loading method and device
CN117056040A (en) Micro-service application adjusting method and device, electronic equipment and storage medium

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