Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing the devices, modules or units, and are not used for limiting the devices, modules or units to be different devices, modules or units, and also for limiting the sequence or interdependence relationship of the functions executed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
To make the objects, technical solutions and advantages of the present disclosure more apparent, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings.
First, it should be noted that if a class is desired to be accessed in java, the class needs to be loaded by a class loader for access, and the class generally exists in a manner of being attached to a code package file, and only when the corresponding code package file is loaded, the class in the code package file can be used.
When an application is installed, a main code package file in an installation package can be automatically optimized, and the main code package file is loaded into a class loader of the application directly by default when the application is started, so that classes in the main code package file can be directly accessed, but secondary code package files except the main code package file can be optimized after being processed and then loaded into the class loader. The classes therein can be used normally. Otherwise, when these classes are accessed, these code package files cannot be found, causing a crash.
The present disclosure provides an application starting method, an application starting apparatus, an electronic device, and a computer-readable storage medium, which aim to solve the above technical problems of the prior art.
The following describes the technical solutions of the present disclosure and how to solve the above technical problems in specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
An embodiment of the present disclosure provides a method for starting an application, as shown in fig. 1, the method includes:
step S101: when detecting that the application starts triggering operation, acquiring related information of a code packet file of the application;
step S102: acquiring a preset function in a virtual machine;
step S103: performing corresponding processing on the related information of the code packet file based on a preset function to obtain a code packet file object; wherein, the code package file object comprises starting information;
step S104: and starting the application according to the starting information.
The application start triggering operation may be when the application is installed for the first time, or when the application is upgraded, or when the application is restarted after installation or upgrade. At this time, the relevant information in the code package file of the application may be obtained first, and then the preset function may be obtained from the function registry inside the virtual machine through the dlsym function. Optionally, the preset function may include a function for loading the related information of the code packet file, or may be a function for optimizing the related information of the code packet file.
After the information related to the code package file is obtained after the preset function is obtained, corresponding loading processing or optimization processing may be performed on the code package file based on the preset function, and then a processed product, that is, a code package file object, is obtained. Specifically, the start information may be added to a class loader, and the class loader may load a code package file object to use a class in the code package, thereby ensuring the start of the application.
The method and the device have the advantages that the relevant information of the code package file in the application is subjected to relevant processing based on the preset function obtained in the virtual machine, the code package file object is obtained, loading time is saved, the application is started through the starting information in the code package file object, the application can be started quickly, and the installation and upgrading experience of a user is greatly improved.
A possible implementation manner is provided in the embodiments of the present disclosure, as shown in fig. 2, where the related information of the code package file includes a bytecode of the code package file, and the preset function includes a load function;
acquiring relevant information of a code package file of an application, wherein the relevant information comprises the following steps:
step S201: when detecting that the application starts triggering operation, decompressing an installation package of the application to acquire byte codes of a code package file;
step S202: acquiring a loading function in a virtual machine;
if the application is expected to run normally and a series of optimized loading processes of the code package file in the prior art are avoided, the virtual machine can execute the byte codes of the code package file which is not subjected to optimized loading.
Optionally, the byte codes of the code packet file can be obtained by decompressing the application installation packet, and the byte codes of the code packet file can be obtained by extracting the code packet file which falls to the ground after the previous startup is completed, so that the decompression time is saved.
Specifically, a code package file can be obtained by decompressing from the installation package, wherein the file form of the code package file can be dex, and the file name can be class.dex; the byte codes of the code packet file can be read from the code packet file, the specific form of the byte codes can be coded bytes, and the byte codes of the code packet file can be obtained by reading the code packet file into the memory.
After the bytecode of the code packet file is obtained, a loading function in the virtual machine may be called, specifically, an array dvm _ dalvik _ system _ DexFile may be obtained in a function registry of the virtual machine through a dlsym function, and then the loading function _ openDexFile _ bytearrarray may be obtained by querying in the array in a manner of matching element character strings one by one.
Optionally, a code package object may be created in the virtual machine, so that the loading function loads the bytecode of the code package file into the first code package file object in the virtual machine that creates the code package object.
It can be appreciated that if the code package file is not load optimized, but the bytecode of the code package file is loaded, the memMap cannot be assigned in the code, which may cause the application to crash.
By analyzing the code:
if(dvm_dex->dex_object!=NULL){
return dvm_dex->dex_object;
}
if dvm _ dex- > dex _ object is not empty, it will go back directly and not be executed down to where the memMap assignment is needed. Therefore, a code packet object dex _ object can be created inside the virtual machine, such as pDvmDex, so that the loading function loads the bytecode of the code packet file into the first code packet file object of the code in the virtual machine creating the code packet object dex _ object, thereby avoiding the crash of the application when the application is started.
The method comprises the following steps of carrying out corresponding processing on relevant information of a code package file based on a preset function to obtain a code package file object, wherein the method comprises the following steps:
step S203: loading the byte codes of the code packet file into a first code packet file object based on a loading function; the first code packet file object comprises first starting information;
after obtaining the loading function _ openDexFile _ bytearray from the virtual machine, the bytecode of the code package file may be loaded as a legal first code package file object based on the loading function.
Optionally, loading the bytecode of the code package file into a first code package file object based on a loading function, including:
calling a loading function, and generating a pointer based on the byte codes of the code packet file;
and after the pointer is implanted into the virtual machine, constructing a first code packet file object based on the address of the pointer.
Optionally, another loading function dvmrawdefilenopenarray may be invoked to process the bytecode of the code package file, an original first code package file object is generated first, and then a pointer dexorajar is generated via the original first code package file object. The pointer DexOrJar can be implanted into the virtual machine, so that the virtual machine can construct a legal first code packet file object by using the address of the pointer DexOrJar as a cookie. And the first code packet file object comprises first starting information, and the application can be started according to the first starting information.
Starting the application according to the starting information, comprising:
step S204: and starting the application according to the first starting information.
Optionally, the first start information may be added to a class loader of the virtual machine, so that the class loader loads the first code package file object to start the application.
Specifically, makeDexElements may be called to add the first start information to the class loader PathClassLoader, and the class loader PathClassLoader may load the class in the first code package file object usage code package, thereby ensuring the start of the application.
Optionally, after the first installation or update, the adopted bytecode for directly loading the code package file by using the loading function can save loading time to a certain extent and optimize upgrade experience. However, in the long term, the code package file may be optimized in the prior art in the subsequent starting process, and then the starting process may be performed based on the optimized file. Therefore, there is also a need to optimize the code package file at the appropriate time in the background after the first installation or update is completed.
According to the method and the device, the byte codes of the code package file are obtained by decompressing from the installation package, the loading function is obtained from the virtual machine, the byte codes of the code package file package can be directly loaded based on the obtained loading function, so that a legal first code package file object is formed, the loading time is greatly shortened, the first code package file object contains the first starting information, the application is started through the first starting information, the starting and loading time is saved, and the installation and upgrading experience of a user is improved.
A possible implementation manner is provided in the embodiments of the present disclosure, as shown in fig. 3, where the relevant information of the code package file includes the code package file, and the preset function includes an optimization function;
acquiring relevant information of a code package file of an application, wherein the relevant information comprises the following steps:
step S301: when detecting that the application starts triggering operation, decompressing an installation package of the application to acquire a code package file;
step S302: obtaining an optimization function in a virtual machine;
when the code package is started or updated for the first time, compared with the prior art that the code package file is compressed and then optimized, the code package file can be not compressed, but the code package file obtained by decompression in the installation package is directly obtained, then the uncompressed code package file is directly optimized, and the whole starting process is also optimized to a certain extent.
It should be noted that, the disk space occupied by the uncompressed code package file is doubled compared with the compressed code package file, so that the uncompressed code package file can be directly optimized under the condition of sufficient disk space.
After the code package file is obtained by decompression from the installation package, in order to avoid the problem of SIGSTKFLT signal crash, the obtained code package file can be processed by acquiring an optimization function dvmrawdefileopen in the virtual machine through a dlsym function.
It should be noted that the SIGSTKFLT signal is a signal specific to the virtual machine, and it is only when the virtual machine wants to suspend all threads but the thread cannot respond, and it will send this signal to the responding thread, so that the application crashes.
The method comprises the following steps of carrying out corresponding processing on relevant information of a code package file based on a preset function to obtain a code package file object, wherein the method comprises the following steps:
step S303: optimizing the code packet file based on an optimization function to obtain a second code packet file object, wherein the second code packet file object comprises second starting information;
generally, the virtual machine is in running state when executing java code, but if the JNI method is called, the state is switched to native state, and if the state is in native state, the virtual machine does not require that the thread must be suspended. Specifically, if the code package file is directly optimized by using an optimization function dvmRawDexFileOpen inside the virtual machine in the native state to obtain a second code package file object without java, the native state can also be always maintained, so that the problem of SIGSTKFLT signals is solved.
Starting the application according to the starting information, comprising:
step S304: and starting the application according to the second starting information.
Optionally, the second start information may be added to a class loader of the virtual machine, so that the class loader loads the second code package file object to start the application.
Specifically, makeDexElements may be called to add the second start information to the class loader PathClassLoader, and the class loader PathClassLoader may load a class in the second code package file object usage code package, thereby ensuring the start of the application.
According to the method and the device for loading the code package file, the code package file is obtained by decompressing the installation package, the optimization function is obtained from the virtual machine, the code package file or the code package file is optimized based on the obtained optimization function, a legal second code package file object is obtained, loading time is greatly shortened, the second code package file object comprises second starting information, the application is started through the second starting information, starting and loading time is saved, and installation and upgrading experience of a user is improved.
Optionally, in an actual operation process, to avoid the problem of the SIGSTKFLT signal, the operation of starting the application according to the second start information and the operation of optimizing the code package file based on the optimization function to obtain the second code package file object may be placed in different processes.
It should be noted that, if the second code package file object is obtained by optimizing the code package file without using a separate process, the start process is prevented from starting the application by using the second code package file object, referring to fig. 4.
Optionally, when the second code package file object is loaded through the class loader, the operation of optimizing the code package file based on the optimization function to obtain the second code package file object may be suspended
Specifically, referring to fig. 5, first, an optimization process starts to execute, a mutex lock is obtained, and then an optimization function dvmRawDexFileOpen is used to perform optimization processing on a code package file to obtain a second code package file object. After the optimization process finishes processing the first code packet file, the optimization process can acquire the preparation lock first and then release the preparation lock to continue to optimize the next code packet file because no other preparation lock is held.
At this time, the starting process or other non-optimization processes are started, the preparation lock is successfully acquired first, then the mutual exclusion lock is acquired in a blocking manner, and at this time, the optimization process can only wait for the release of the mutual exclusion lock because the mutual exclusion lock is acquired in the previous step.
After the second code packet file is processed by the optimization process, the preparation lock is detected to be held by other processes, so that the acquisition fails, the optimization of the code packet file is stopped, and the mutual exclusion lock is released and quit.
At this point, the initiating process may successfully acquire the mutex lock and immediately release the prepare lock so that other processes may acquire it. And then, after the loading of the second code file object is finished and started, releasing the mutual exclusion lock, continuing to execute a subsequent service flow, and finally calling an optimization process and finishing the optimization processing of the original code packet file.
In general, in this mode, the optimization process can actively discover the second code packet file object of other processes, thereby interrupting the optimization process of the code packet file and releasing the mutual exclusion lock. The starting process does not need to wait for the whole code package file to be optimized, and the subsequent operation can be continuously executed only by waiting for the optimization process to complete the optimization of the latest code package file. Network resources are reasonably utilized.
An embodiment of the present disclosure provides an application starting apparatus, and as shown in fig. 6, the application starting apparatus 60 may include: a first acquisition module 601, a second acquisition module 602, a processing module 603, and an activation module 604, wherein,
a first obtaining module 601, configured to obtain relevant information of a code package file of an application when an application start triggering operation is detected;
a second obtaining module 602, configured to obtain a preset function in the virtual machine;
the processing module 603 is configured to perform corresponding processing on the relevant information of the code package file based on a preset function, so as to obtain a code package file object; wherein, the code package file object comprises starting information;
a starting module 604, configured to start the application according to the starting information.
The application start triggering operation may be when the application is installed for the first time, or when the application is upgraded, or when the application is restarted after installation or upgrade. At this time, the relevant information in the code package file of the application may be obtained first, and then the preset function may be obtained from the function registry inside the virtual machine through the dlsym function. Optionally, the preset function may include a function for loading the related information of the code packet file, or may be a function for optimizing the related information of the code packet file.
After the information related to the code package file is obtained after the preset function is obtained, corresponding loading processing or optimization processing may be performed on the code package file based on the preset function, and then a processed product, that is, a code package file object, is obtained. Specifically, the start information may be added to a class loader, and the class loader may load a code package file object to use a class in the code package, thereby ensuring the start of the application.
The method and the device have the advantages that the relevant information of the code package file in the application is subjected to relevant processing based on the preset function obtained in the virtual machine, the code package file object is obtained, loading time is saved, the application is started through the starting information in the code package file object, the application can be started quickly, and the installation and upgrading experience of a user is greatly improved.
Fig. 7 is a schematic structural diagram of an application starting apparatus provided in an embodiment of the present disclosure, and as shown in fig. 7, the apparatus of the embodiment may include:
a first obtaining first sub-module 701, configured to, when detecting that an application starts a trigger operation, decompress an installation package of an application to obtain a bytecode of a code package file;
a second obtaining first sub-module 702, configured to obtain a loading function in the virtual machine;
a loading module 703, configured to load the bytecode of the code package file into a first code package file object based on a loading function; the first code packet file object comprises first starting information;
the first start sub-module 704 is configured to start the application according to the first start information.
The application starting apparatus of this embodiment can execute the application starting method shown in the above embodiments of the present disclosure, and the implementation principles thereof are similar, and are not described herein again.
According to the method and the device, the byte codes of the code package file are obtained by decompressing from the installation package, the loading function is obtained from the virtual machine, the byte codes of the code package file package can be directly loaded based on the obtained loading function, so that a legal first code package file object is formed, the loading time is greatly shortened, the first code package file object contains the first starting information, the application is started through the first starting information, the starting and loading time is saved, and the installation and upgrading experience of a user is improved.
Fig. 8 is a schematic structural diagram of an application starting apparatus provided in an embodiment of the present disclosure, and as shown in fig. 8, the apparatus of this embodiment may include:
the first obtaining second sub-module 801 is configured to decompress an installation package of an application to obtain a code package file when detecting an application start triggering operation;
a second obtaining second sub-module 802, configured to obtain an optimization function in the virtual machine;
the optimization module 803 is configured to optimize the code packet file based on an optimization function to obtain a second code packet file object, where the second code packet file object includes second start information;
and the second starting sub-module 804 is configured to start the application according to the second starting information.
The application device of this embodiment can execute the application starting method shown in the above embodiments of the present disclosure, and the implementation principles thereof are similar and will not be described herein again.
According to the method and the device for loading the code package file, the code package file is obtained by decompressing the installation package, the optimization function is obtained from the virtual machine, the code package file or the code package file is optimized based on the obtained optimization function, a legal second code package file object is obtained, loading time is greatly shortened, the second code package file object comprises second starting information, the application is started through the second starting information, starting and loading time is saved, and installation and upgrading experience of a user is improved.
Referring now to FIG. 9, shown is a schematic diagram of an electronic device 900 suitable for use in implementing embodiments of the present disclosure. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., car navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 9 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
The electronic device includes: a memory and a processor, wherein the processor herein may be referred to as a processing device 901 described below, and the memory may include at least one of a Read Only Memory (ROM)902, a Random Access Memory (RAM)903, and a storage device 908, which are described below:
as shown in fig. 9, the electronic device 900 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 901 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage means 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data necessary for the operation of the electronic apparatus 900 are also stored. The processing apparatus 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.
Generally, the following devices may be connected to the I/O interface 905: input devices 906 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 907 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 908 including, for example, magnetic tape, hard disk, etc.; and a communication device 909. The communication device 909 may allow the electronic apparatus 900 to perform wireless or wired communication with other apparatuses to exchange data. While fig. 9 illustrates an electronic device 900 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication device 909, or installed from the storage device 908, or installed from the ROM 902. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing apparatus 901.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText transfer protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to:
when detecting that the application starts triggering operation, acquiring related information of a code packet file of the application;
acquiring a preset function in a virtual machine;
performing corresponding processing on the related information of the code packet file based on a preset function to obtain a code packet file object; wherein, the code package file object comprises starting information;
and starting the application according to the starting information.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules or units described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the designation of a module or unit does not in some cases constitute a limitation of the unit itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, there is provided an application starting method including:
when detecting that the application starts triggering operation, acquiring related information of a code packet file of the application;
acquiring a preset function in a virtual machine;
performing corresponding processing on the related information of the code packet file based on a preset function to obtain a code packet file object; wherein, the code package file object comprises starting information;
and starting the application according to the starting information.
Optionally, the related information of the code packet file includes a bytecode of the code packet file, and the preset function includes a loading function;
acquiring relevant information of a code package file of an application, wherein the relevant information comprises the following steps:
decompressing the installation package of the application to obtain the byte codes of the code package file;
the method comprises the following steps of carrying out corresponding processing on relevant information of a code package file based on a preset function to obtain a code package file object, wherein the method comprises the following steps:
loading the byte codes of the code packet file into a first code packet file object based on a loading function; the first code packet file object comprises first starting information;
starting the application according to the starting information, comprising:
and starting the application according to the first starting information.
Optionally, a code package object may be created in the virtual machine, so that the loading function loads the bytecode of the code package file as the first code package file object in the virtual machine that created the code package object.
Optionally, loading the bytecode of the code package file into a first code package file object based on a loading function, including:
calling a loading function, and generating a pointer based on the byte codes of the code packet file;
and after the pointer is implanted into the virtual machine, constructing a first code packet file object based on the address of the pointer.
Optionally, the related information of the code packet file includes the code packet file, and the preset function includes an optimization function;
acquiring relevant information of a code package file of an application, wherein the relevant information comprises the following steps:
decompressing an installation package of the application to obtain a code package file;
the method comprises the following steps of carrying out corresponding processing on relevant information of a code package file based on a preset function to obtain a code package file object, wherein the method comprises the following steps:
optimizing the code packet file based on an optimization function to obtain a second code packet file object, wherein the second code packet file object comprises second starting information;
starting the application according to the starting information, comprising:
and starting the application according to the second starting information.
Optionally, starting the application according to the second start information and optimizing the code package file based on the optimization function to obtain the second code package file object are operations performed in different processes.
Optionally, the second start information may be added to a class loader of the virtual machine, so that the class loader loads the second code package file object to start the application, and when the second code package file object is loaded by the class loader, an operation of optimizing the code package file based on the optimization function to obtain the second code package file object is suspended.
According to one or more embodiments of the present disclosure, there is provided an application starting apparatus including:
the first acquisition module is used for acquiring relevant information of a code package file of an application when detecting application starting triggering operation;
the second acquisition module is used for acquiring a preset function in the virtual machine;
the processing module is used for correspondingly processing the relevant information of the code packet file based on a preset function to obtain a code packet file object; wherein, the code package file object comprises starting information;
and the starting module is used for starting the application according to the starting information.
According to one or more embodiments of the present disclosure, there is provided an electronic device including:
one or more processors;
a memory;
one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to perform operations corresponding to the application launching methods described above.
According to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium including:
the computer storage medium is used for storing computer instructions which, when run on a computer, enable the computer to implement the application launching method described above.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.