A Java object creation method, chip, and device
By scanning the heap space in the Java card to obtain free flags and concatenating the data to write it all at once to the non-volatile storage area, the problem of low Java object creation efficiency is solved, realizing a more efficient Java object creation process and improving production efficiency and user experience.
Patent Information
- Application Number
- CN202210178878.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2042-02-25
AI Technical Summary
Existing technologies are inefficient when creating Java objects in Java cards, resulting in time-consuming installation and personalization processes, which impacts productivity and user experience.
By scanning the heap space to obtain free space identifiers, generating object attribute identifiers and free space identifiers, and concatenating the data, the data is written to the non-volatile storage area in one go, reducing the number of write operations and improving creation efficiency.
It improves the efficiency of Java object creation, reduces complexity, and enhances productivity and user experience.
Smart Images

Figure CN116700835B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of security chip technology, and more specifically, to a Java object creation method, chip, and device. Background Technology
[0002] Java Card technology, as an operating system implementation method, has been widely used in security chips such as Secure Elements and Smart Cards. Java Card technology is a platform-independent, multi-application virtual machine platform that allows multiple Java Applets to run simultaneously on a security chip while ensuring security. Therefore, Java Card technology is particularly suitable for resource-constrained security chips.
[0003] When a Java program runs, Java objects are dynamically created and stored in memory, and Java Card technology is no exception. Java objects on a Java Card are stored by default in non-volatile storage, typically EEPROM (Electrically Erasable Programmable Read-Only Memory) or Flash Memory. Since writing to non-volatile storage is significantly more time-consuming than running the Central Processing Unit (CPU) and writing to Random Access Memory (RAM), improving the efficiency of Java object creation has always been a key focus and challenge for Java Card technology. Summary of the Invention
[0004] This application provides an object storage method, chip, and device that can improve efficiency when creating Java objects.
[0005] Firstly, it provides a method for creating Java objects, including:
[0006] Scan the heap space to obtain a first free space identifier; the first free space identifier is used to indicate that the heap space after the initial address of the first free space identifier is free space; the heap space is a contiguous segment of address space in the non-volatile storage area used to store the Java object;
[0007] An object attribute identifier is generated based on the Java object, and the object attribute identifier includes the size information of the Java object;
[0008] A second free space identifier is generated, which indicates that the heap space after the initial address of the second free space identifier is free space; wherein the values of the first free space identifier and the second free space identifier are different from the values of the object attribute identifier;
[0009] The object attribute identifier, the Java object, and the second free space identifier are concatenated to generate concatenated data of the Java object;
[0010] Starting from the initial address of the first free space identifier, the concatenated data is written, such that the concatenated data covers the first free space identifier.
[0011] In one possible implementation, scanning the heap space to obtain the first free space identifier includes:
[0012] The heap space is read from the starting address of the heap space. The object attribute identifier and the first free space identifier are obtained according to their values. If the object attribute identifier is read, a jump is performed according to the size information of the Java object in the object attribute identifier until the first free space identifier is read.
[0013] In one possible implementation, before generating the object attribute identifier based on the Java object, the method further includes determining whether the free space of the heap space is sufficient to store the Java object based on the size information of the Java object and the first free space identifier.
[0014] In one possible implementation, determining whether the free space is sufficient to store the Java object based on the size information of the Java object and the first free space identifier includes:
[0015] Obtain the initial address of the first free space identifier in the heap space and the tail address of the heap space;
[0016] The size information of the free space in the heap space is obtained based on the difference between the initial address and the tail address;
[0017] Based on the size information of the Java object and the size information of the free space in the heap, determine whether the free space is sufficient to store the Java object.
[0018] In one possible implementation, before determining whether the free space is sufficient to store the Java object based on the size information of the Java object and the first free space identifier, the method further includes:
[0019] Obtain the size information of the free space in the heap space;
[0020] Write the size information of the free space in the heap space into the first free space identifier;
[0021] The step of determining whether the free space is sufficient to store the Java object based on the size information of the Java object and the first free space identifier includes: determining whether the free space is sufficient to store the Java object based on the size information of the free space in the first free space identifier and the size information of the Java object.
[0022] In one possible implementation, the value of the second free space identifier is the same as the value of the first free space identifier.
[0023] In one possible implementation, the value of the free space identifier is the same as the initial value of the non-volatile memory area.
[0024] In one possible implementation, the object attribute identifier further includes a distinguishing identifier for distinguishing it from the first free space identifier; the distinguishing identifier is also used to locate the object attribute identifier.
[0025] In one possible implementation, before writing the concatenated data starting from the initial address identified by the first free space, the method further includes: determining whether the Java object is being created for the first time in the current transaction; if so, backing up the initial address identified by the first free space.
[0026] In one possible implementation, the method further includes: in the event of a power failure or transaction abort, performing a transaction rollback to restore the first free space identifier to the backed-up initial address.
[0027] In a second aspect, a chip is provided, comprising a processing module, an interface, and a storage module, wherein the processing module is used to call and run a computer program stored in the storage module to implement the method in any possible implementation of the first aspect.
[0028] In one possible implementation, the storage module includes a non-volatile storage area and other storage areas; the non-volatile storage area is used to store the Java object and system data and / or application data generated by the operating system; the computer program is stored in the other storage areas.
[0029] Thirdly, an apparatus is provided that includes the chip as described in the second aspect.
[0030] The solution in this application involves scanning to obtain a first free space identifier, generating an object attribute identifier based on the Java object, then generating a second free space identifier. The object attribute identifier, the Java object, and the second free space identifier are then concatenated to obtain concatenated data of the Java object. This concatenated data is written to the non-volatile storage area in one go. Compared to existing technologies that require at least two write operations to the non-volatile storage area when creating a Java object, this improves the efficiency of Java object creation. Furthermore, by ensuring that the value of the second free space identifier is the same as the value of the first free space identifier, and that the value of the first free space identifier is the same as the initial value of the non-volatile storage area, the complexity of Java object creation can be further reduced, and the efficiency of Java object creation can be improved. Attached Figure Description
[0031] Figure 1 This is a schematic diagram of a Java object creation process provided in an embodiment of this application.
[0032] Figure 2 This is a schematic diagram illustrating the space usage of Java object creation according to an embodiment of this application.
[0033] Figure 3 This is a schematic diagram illustrating another Java object creation process provided in an embodiment of this application.
[0034] Figure 4 This is a schematic diagram illustrating another Java object creation process provided in an embodiment of this application.
[0035] Figure 5 This is a schematic diagram of the structure of a chip provided in an embodiment of this application. Detailed Implementation
[0036] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0037] The embodiments of this application are applicable to secure elements using Java card technology, such as embedded secure elements (eSE), smart cards, eSIM (eSIM) and other security chips. Furthermore, the secure element can also be integrated into an electronic device; the embodiments disclosed herein do not limit this.
[0038] It should be understood that the specific examples in this document are only intended to help those skilled in the art better understand the embodiments of this application, and are not intended to limit the scope of the embodiments of this application.
[0039] It should also be understood that the formulas in the embodiments of this application are merely examples and are not intended to limit the scope of the embodiments of this application. The formulas can be modified, and these modifications should also fall within the scope of protection of this application.
[0040] It should also be understood that, in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0041] It should also be understood that the various implementation methods described in this specification can be implemented individually or in combination, and the embodiments of this application are not limited in this respect.
[0042] Unless otherwise stated, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this application includes any and all combinations of one or more of the associated listed items.
[0043] Generally, creating a Java object involves at least two steps: Step 1, allocating space in the heap space where the Java object is stored; Step 2, writing the Java object to this space. These two steps require at least two write operations to the non-volatile storage area. In Step 1, the heap management information storing the Java object is updated to ensure the consistency of persistent data in the Java card and the atomicity of persistent data updates. Since this heap management information is stored in the non-volatile storage area, there is at least one write operation to the non-volatile storage area in Step 1. In Step 2, writing the Java object to the space allocated in Step 1 also requires at least one write operation to the non-volatile storage area. Therefore, this method of creating a Java object requires at least two write operations to the non-volatile storage area. When installing and personalizing Java applications, there are numerous Java object creation operations, resulting in a large number of write operations to the non-volatile storage area, making the installation and personalization of Java applications very time-consuming. When this installation and personalization occurs in the production stage, it will affect production efficiency; when it occurs during end-user use, it will affect the end-user experience.
[0044] In view of this, this application provides a Java object creation method, chip, and device that can reduce the operation of writing to non-volatile storage areas when creating Java objects, improve the efficiency of creating Java objects, thereby improving production efficiency in the production stage and enhancing user experience in the end-user stage.
[0045] The first aspect of this application provides a method for creating Java objects.
[0046] Below, also refer to Figure 1 and Figure 2 This application provides a detailed description of the Java object creation method provided in the embodiments. Figure 1 This is a schematic diagram illustrating a Java object creation process provided in an embodiment of this application. Figure 2 This is a schematic diagram illustrating the space usage of Java object creation according to an embodiment of this application. As shown in the figure:
[0047] S101: Scan the heap space 202 and obtain the first free space identifier 203.
[0048] Specifically, before creating Java object 214, the heap space 202 needs to be scanned to obtain the first free space identifier 203. Scanning the heap space 202 refers to scanning from the starting address 200 of the heap space 202 to the highest address where data is stored in the heap space 202, and obtaining the first free space identifier 203 by means of preset specific conditions.
[0049] The first free space identifier 203 is used to indicate that the heap space 202 after the initial address 208 of the first free space identifier 203 is free space 206. The free space 206 refers to the remaining space of the heap space 202 after storing more than one Java object. This remaining space is in an idle state and can be used to store Java objects.
[0050] With the value of the first free space identifier 203 as a preset specific condition, the first free space identifier 203 can be obtained by searching for its value during the scanning of the heap space 202.
[0051] Preferably, to improve the efficiency of Java object creation, the value of the free space identifier is the same as the initial value of the non-volatile storage area 201. For example, the initial value of the non-volatile storage area 201 may include four bytes of 0, i.e., "0x00000000", which is located at the starting address 200 of the heap space 202; the value of the free space identifier also includes four bytes of 0, i.e., "0x00000000". Before creating the first Java object in the heap space 202, a free space identifier needs to be written at the beginning of the heap space 202 to indicate that the heap space 202 is in a free state. If the value of the free space identifier is the same as the initial value of the non-volatile storage area 201, the operation of writing the free space identifier at the starting address 200 of the heap space 202 can be omitted, and the creation of the first Java object can be performed directly. It is understood that the initial values of different non-volatile memory areas 201 may be different, but the initial values of the non-volatile memory areas 201 can be obtained according to the inherent properties of the non-volatile memory corresponding to the non-volatile memory area 201 before the first Java object is created.
[0052] S102: Generate object attribute identifier 205 based on Java object 214.
[0053] Specifically, in order to effectively distinguish between object attribute identifier 205 and the first free space identifier 203, the value of object attribute identifier 205 can include any fixed value other than the value of the first free space identifier 203. For example, after selecting the value of the first free space identifier 203, the range of values for object attribute identifier 205 can be agreed upon, and the value of the first free space identifier 203 can be excluded from the range of values for object attribute identifier 205.
[0054] It should be understood that generating object attribute identifier 205 does not include the operation of writing to non-volatile storage area 201. For example, generating object attribute identifier 205 may include writing the data of object attribute identifier 205 into RAM variable.
[0055] The object attribute identifier 205 includes the size information of the Java object 214.
[0056] Optionally, the object attribute identifier 205 may further include an occupancy identifier. The occupancy identifier is used to indicate that a segment of heap space following the end address 215 where the object attribute identifier 205 is located is occupied.
[0057] Optionally, the object attribute identifier 205 further includes a distinguishing identifier for differentiating itself from the first free space identifier 203. The first free space identifier 203 may include a vacancy identifier, which indicates that the heap space after the initial address 208 of the first free space identifier 203 is free space. The data length of the distinguishing identifier is the same as the data length of the vacancy identifier. For example, object attribute identifier 205 may include 4 bytes, one of which can be a distinguishing identifier "0xA5", which distinguishes object attribute identifier 205 from the first free space identifier 203; the remaining 3 bytes can be used to store the size information and / or occupancy identifier of the Java object 214 mentioned above; the first free space identifier 203 may include 4 bytes, one of which is a vacancy identifier "0x00", which can be used to indicate that the heap space after the initial address 208 of the first free space identifier 203 is free space, and is used to distinguish it from the distinguishing identifier "0xA5" in object attribute identifier 205. The two have different values, but the data length of both is 1 byte. The remaining 3 bytes of the first free space identifier 203 can store other information, such as the size information of free space 206. It should be understood that the length of the first free space identifier can be flexibly set according to specific circumstances, such as including only 1 byte of vacancy identifier, or further including several bytes of free space size information. For example, in some other embodiments, the length of the empty space identifier is equal to the length of the distinguishing identifier, and the total length of the first free space identifier 203 may not be equal to the total length of the object attribute identifier 205.
[0058] In addition, optionally, the distinguishing identifier of object attribute identifier 205 can also be used to look up object attribute identifier 205.
[0059] Optionally, the Java object 204 and / or Java object 214 can also be managed based on the object attribute identifier 205. For example, the object attribute identifier 205 may include numbering information corresponding to the Java object 204 and the Java object 214, and then, operations such as calling, deleting, and expanding the Java object 204 and / or Java object 214 can be performed through this numbering information.
[0060] S103: Generate the second free space identifier 209.
[0061] The method for determining the value of the second free space identifier 209 is similar to the method for determining the value of the first free space identifier 203 in this embodiment, and will not be described again here. It should be understood that the generation of the second free space identifier 209 is similar to the generation of the object attribute identifier 205 mentioned above, and neither of them includes the operation of writing to the non-volatile storage area 201, and will not be described again here.
[0062] S104: Combine object attribute identifier 205, Java object 214, and second free space identifier 209 to generate concatenated data 213 of the Java object.
[0063] The process of generating spliced data 213 of Java objects by splicing object attribute identifier 205, Java object 214, and second free space identifier 209 refers to splicing the above three together to form a continuous spliced data 213 of Java objects.
[0064] Preferably, the above splicing operation splices the three elements in the following order: the address of object attribute identifier 205 first, the address of Java object 214 in the middle, and the address of the second free space identifier 209 last.
[0065] S105: Starting from the initial address 208 of the first free space identifier 203, write the concatenated data 213.
[0066] Continue to refer to Figure 2 Starting from the initial address 208 of the first free space identifier 203, concatenated data 213 is written. Specifically, the concatenated data 213 is written into a continuous free space 206 starting from the initial address 208 of the first free space identifier 203, so that the concatenated data 213 covers the first free space identifier 203.
[0067] Optionally, the concatenated data 213 covering the first free space identifier 203 means that the concatenated data 213 covers the empty space identifier in the first free space identifier 203, so that the covered first free space identifier 203 cannot be read during the scanning of the heap space 202 when other Java objects are created later. For example, when two Java objects are created in the heap space 202, the identifiers that can be read only include two object attribute identifiers 205 and one second free space identifier 209, that is, there is only one free space identifier in the heap space 202.
[0068] Preferably, the object attribute identifier 205 can cover the first free space identifier 203, that is, the length of the object attribute identifier 205 is greater than or equal to the length of the first free space identifier 203.
[0069] Generally, the address of the second free space identifier 209 is different from the address of the first free space identifier 203. The initial address 212 of the second free space identifier 209 can be used as the starting address for concatenating the data of the next Java object, and the above operation of creating Java objects can be repeated until the heap space 202 is full.
[0070] Preferably, to reduce the complexity of Java object creation, the value of the second free space identifier 209 is the same as the value of the first free space identifier 203. On the one hand, no additional settings are needed for the value of the second free space identifier 209; on the other hand, if the initial address 212 of the second free space identifier 209 is used as the starting address to write the concatenated data of the next Java object, then during the scanning of the heap space 202 as described in S101 of this embodiment, it is not necessary to change the preset specific conditions for finding the value of the first free space identifier 203 to obtain the second free space identifier 209. That is, the fact that the value of the second free space identifier 209 is the same as the value of the first free space identifier 203 can reduce the complexity of Java object creation. For example, in one possible case, both the first free space identifier 203 and the second free space identifier 209 include only a 1-byte empty space identifier "0x00".
[0071] Optional, continue to refer to Figure 1 and Figure 2 The above S101 may include: reading the heap space 202 from the starting address 200 of the heap space 202, obtaining the object attribute identifier 205 and the first free space identifier 203 respectively according to the values of the object attribute identifier 205 and the first free space identifier 203; if the object attribute identifier 205 is read, then jump according to the size information of the Java object of the object attribute identifier 205 until the first free space identifier 203 is read.
[0072] like Figure 1 As described in the corresponding embodiment, the value of the first free space identifier 203 is different from the value of the object attribute identifier 205. Therefore, it is possible to determine whether the identifier read is the object attribute identifier 205 or the first free space identifier 203 based on the value of the object attribute identifier 205 and the value of the first free space identifier 203.
[0073] Optionally, as mentioned above, they can be distinguished from each other based on the distinguishing identifier of object attribute identifier 205 and the empty space identifier of first free space identifier 203 (for example, by...). Figure 1 In embodiment S102, the distinguishing identifier “0xA5” in the object attribute identifier 205 and the empty space identifier “0x00” in the first free space identifier 203 can be used to distinguish each other. In order to improve the efficiency of reading the above identifiers, a jump can be made according to the size information of the Java object 204 in the object attribute identifier 205 until the first free space identifier 203 is read. The jump means that the space occupied after the end address 215 where the object attribute identifier 205 is located is not read, that is, the Java object 204 is not read, and the jump is made directly to the next object attribute identifier 205 or free space identifier.
[0074] Optionally, when object attribute identifier 205 is read, it can be determined that a segment of heap space after the end address 215 where object attribute identifier 205 is located is occupied based on the occupancy identifier of object attribute identifier 205. Furthermore, the size of the occupied segment of space can be obtained based on the size information of Java object 204 of object attribute identifier 205, that is, the size of the occupied segment of space is equal to the size of Java object 204 concatenated by object attribute identifier 205.
[0075] Also refer to Figure 3 and Figure 2 , Figure 3 This is a schematic diagram illustrating another Java object creation process provided in an embodiment of this application. To improve the efficiency of Java object creation, in Figure 1 The corresponding embodiment further includes, before S102: determining whether the free space 206 is sufficient to store the Java object 214 based on the size information of the Java object and the first free space identifier 203. If the determination result is sufficient to store the Java object 214, then the steps after S102 are executed, which can avoid invalid operations in the process of creating the Java object 214, improve the efficiency of creating the Java object 214, and save system resources.
[0076] One implementation specifically includes the following steps:
[0077] S301: Obtain the initial address 208 of the first free space identifier 203 in the heap space 202 and the tail address 211 of the heap space 202;
[0078] The first free space identifier 203 can be obtained based on its value, and the initial address 208 of the first free space identifier 203 in the heap space 202 can be obtained further; the tail address 211 of the heap space 202 can be the address corresponding to the maximum value among all addresses in the heap space 202.
[0079] S302: Obtain the size information of the free space 206 of the heap space 202 based on the difference between the initial address 208 and the tail address 211;
[0080] S303: Based on the size information of Java object 214 and the size information of free space 206 in heap space 202, determine whether the free space 206 in heap space 202 is sufficient to store Java object 214.
[0081] If the size of the free space 206 in the heap space 202 is greater than or equal to the size of the Java object 214, then the Java object 214 can be stored in the free space 206; otherwise, it cannot be stored in the free space 206.
[0082] In another implementation, while referring to Figure 4 and Figure 2 , Figure 4 This is a schematic diagram illustrating another Java object creation process provided in this application embodiment. Specifically, before determining whether the free space 206 is sufficient to store the Java object 214 based on the size information of the Java object 214 and the first free space identifier 203, the method further includes the following steps:
[0083] S401: Obtain the size information of the free space 206 in the heap space 202;
[0084] Specifically, for example, first obtain the total size of heap space 202, then obtain the size of the Java objects, and use the difference between the two to obtain the size of free space 206. When multiple Java objects are created, the total size of all Java objects can be obtained based on the size of each Java object, and then the size information of free space 206 can be obtained by using the difference between the total size of heap space 202 and the total size of all Java objects.
[0085] S402: Write the size information of the free space 206 of the heap space 202 into the first free space identifier 203;
[0086] Specifically, for example, the first free space identifier 203 can be 4 bytes in size. One of these bytes can be as follows: Figure 1 The empty space identifier described in the embodiment (e.g., Figure 1 In embodiment S102, the first free space identifier 203 has an empty space identifier "0x00", and the remaining 3 bytes are used to write the size information of the free space 206.
[0087] S403: Determining whether the free space is sufficient to store the Java object based on the size information of the Java object and the first free space identifier includes: determining whether the free space 206 of the heap space 202 is sufficient to store the Java object 214 based on the size information of the free space 206 in the first free space identifier 203 and the size information of the Java object.
[0088] Specifically, before writing the concatenated data 213, it can be determined whether the size of the free space 206 is sufficient to write the Java object 214 based on the size information of the free space 206 in the first free space identifier 203.
[0089] Optional, continue to refer to Figure 1 and Figure 2 ,exist Figure 1Before S105, the method further includes: determining whether the Java object 214 is being created for the first time in the current transaction; if so, backing up the initial address 208 of the first free space identifier 203.
[0090] Optionally, a transaction rollback can be performed in the event of a power outage or transaction termination. The transaction refers to the mechanism in Java Card technology used to ensure the atomicity of updates to non-volatile data. Multiple transactions may exist when creating multiple Java objects; the current transaction refers to the transaction corresponding to the creation of the current Java object.
[0091] For example, if Java object 214 is being created for the first time in the current transaction, the initial address 208 of the first free space identifier 203 is backed up. This backup refers to backing up the first free space identifier 203 using the transaction mechanism in Java card technology. Specifically, the backup means storing the initial address 208 in a non-volatile storage area.
[0092] If a power outage or transaction abort occurs during this transaction, during transaction rollback, the first free space identifier 203 can be restored to the backed-up initial address 208 based on the initial address 208 of the first free space identifier 203 stored in the non-volatile storage area. Through backup and rollback operations, data recovery can be achieved in abnormal situations, ensuring the atomicity of transaction processing.
[0093] The Java object creation method provided in this application embodiment, when creating a Java object 214, concatenates the object attribute identifier 205, the Java object 214, and the second free space identifier 209 to generate concatenated data 213. This concatenated data 213 is then written once into the non-volatile storage area 201 where the heap space 202 is located. That is, the creation of the Java object 214 is completed by writing to the non-volatile storage area 201 in one operation. Compared to existing technologies that require at least two write operations to the non-volatile storage area 201 when creating a Java object, this method improves the efficiency of Java object creation. Furthermore, by setting the value of the second free space identifier to be the same as the value of the first free space identifier, the condition for finding the free space identifier is avoided each time a Java object is created, further reducing the complexity of Java object creation. By setting the value of the free space identifier to be the same as the initial value of the non-volatile storage area, the operation of writing the free space identifier at the starting address of the heap space can be eliminated, allowing direct creation of the first Java object, further improving the efficiency of Java object creation.
[0094] A second aspect of the embodiments of this application provides a chip.
[0095] Figure 5This is a schematic diagram of the structure of a chip provided in an embodiment of this application, such as... Figure 5 As shown, the chip 500 includes: a processing module 501, an interface 502, and a storage module 503. The processing module 501 is used to call and run the computer program stored in the storage module 503 to achieve... Figure 1-4 Any of the methods in the illustrated embodiments.
[0096] For example, the storage module 503 of the chip 500 includes a non-volatile storage area and other storage areas; the non-volatile storage area is used to store Java objects and system data and / or application data generated by the operating system (e.g., information generated when backing up the first free space identifier 203); the computer program is stored in the other storage area.
[0097] A third aspect of this application provides an electronic device that may include the chip 500 described in the above embodiments. The chip 500 is used to execute the technical solutions described in the above method embodiments.
[0098] For example, the electronic device provided in this application embodiment may include: a processor, a memory, a communication interface, and a system bus. The memory and the communication interface are connected to the processor via the system bus and communicate with each other. The memory stores computer-executed instructions, and the communication interface communicates with other devices. When the processor executes the computer-executed instructions, it implements the solution described in the above method embodiment.
[0099] It should be understood that the processor in the embodiments of this application can be an integrated circuit chip, such as the chip 500 described above, which has signal processing capabilities. In implementation, each step of the above method embodiments can be completed by the integrated logic circuits in the processor's hardware or by instructions in software form. The processor described above can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above method.
[0100] It is understood that the electronic device memory in the embodiments of this application may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate Synchronous DRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM). It should be noted that the memory used in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0101] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0102] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0103] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0104] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0105] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0106] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0107] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A Java object creation method, characterized in that, The Java object is stored in a non-volatile storage area, and the method includes: Scan the heap space to obtain a first free space identifier; the first free space identifier is used to indicate that the heap space after the initial address of the first free space identifier is free space; the heap space is a contiguous segment of address space in the non-volatile storage area used to store the Java object; An object attribute identifier is generated based on the Java object, and the object attribute identifier includes the size information of the Java object; A second free space identifier is generated, which indicates that the heap space after the initial address of the second free space identifier is free space; wherein, the values of the first free space identifier and the second free space identifier are different from the values of the object attribute identifier; The object attribute identifier, the Java object, and the second free space identifier are concatenated to generate concatenated data of the Java object; Starting from the initial address of the first free space identifier, the concatenated data is written, such that the concatenated data covers the first free space identifier.
2. The method as described in claim 1, characterized in that, The scanning of the heap space to obtain the first free space identifier includes: The heap space is read from the starting address of the heap space. The object attribute identifier and the first free space identifier are obtained according to their values. If the object attribute identifier is read, a jump is performed according to the size information of the Java object in the object attribute identifier until the first free space identifier is read.
3. The method as described in any one of claims 1 or 2, characterized in that, Before generating the object attribute identifier based on the Java object, the method further includes determining whether the free space is sufficient to store the Java object based on the size information of the Java object and the first free space identifier.
4. The method as described in claim 3, characterized in that, The step of determining whether the free space is sufficient to store the Java object based on the size information of the Java object and the first free space identifier includes: Obtain the initial address of the first free space identifier in the heap space and the tail address of the heap space; The size information of the free space in the heap space is obtained based on the difference between the initial address and the tail address; Based on the size information of the Java object and the size information of the free space in the heap, determine whether the free space is sufficient to store the Java object.
5. The method as described in claim 3, characterized in that, Before determining whether the free space is sufficient to store the Java object based on the size information of the Java object and the first free space identifier, the method further includes: Obtain the size information of the free space in the heap space; Write the size information of the free space in the heap space into the first free space identifier; The step of determining whether the free space is sufficient to store the Java object based on the size information of the Java object and the first free space identifier includes: determining whether the free space is sufficient to store the Java object based on the size information of the free space in the first free space identifier and the size information of the Java object.
6. The method as described in claim 1, characterized in that, The value of the second free space identifier is the same as the value of the first free space identifier.
7. The method as described in claim 6, characterized in that, The value of the free space identifier is the same as the initial value of the non-volatile memory area.
8. The method according to any one of claims 1 to 2, 6 to 7, characterized in that, The object attribute identifier also includes a distinguishing identifier, used to differentiate it from the first free space identifier; the distinguishing identifier is also used to locate the object attribute identifier.
9. The method according to any one of claims 1 to 2, 6 to 7, characterized in that, Before writing the concatenated data starting from the initial address identified by the first free space, the method further includes: determining whether the Java object is being created for the first time in the current transaction; if so, backing up the initial address identified by the first free space.
10. The method as described in claim 9, characterized in that, The method further includes: in the event of a power outage or transaction abort, performing a transaction rollback to restore the first free space identifier to the backed-up initial address.
11. A chip, characterized in that, include: A processing module, an interface, and a storage module, wherein the processing module is used to call and run a computer program stored in the storage module to implement the method of any one of claims 1 to 10.
12. The chip as described in claim 11, characterized in that, The storage module includes a non-volatile storage area and other storage areas; the non-volatile storage area is used to store the Java objects and system data and / or application data generated by the operating system; the computer program is stored in the other storage areas.
13. A device, characterized in that, include: The chip as described in claim 12.
Citation Information
Patent Citations
JAVA card object management method
CN102799660A
Garbage collection method, device and equipment for Java virtual machine and storage medium
CN109669759A
