CN111722849B - JAVA language virtual compiling realization method, system and device - Google Patents

JAVA language virtual compiling realization method, system and device Download PDF

Info

Publication number
CN111722849B
CN111722849B CN202010692748.8A CN202010692748A CN111722849B CN 111722849 B CN111722849 B CN 111722849B CN 202010692748 A CN202010692748 A CN 202010692748A CN 111722849 B CN111722849 B CN 111722849B
Authority
CN
China
Prior art keywords
class
java
virtual
file
compiling
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010692748.8A
Other languages
Chinese (zh)
Other versions
CN111722849A (en
Inventor
高新亮
王宏
王小东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sikeyun Beijing Software Technology Co ltd
Original Assignee
Sikeyun Beijing Software Technology 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 Sikeyun Beijing Software Technology Co ltd filed Critical Sikeyun Beijing Software Technology Co ltd
Priority to CN202010692748.8A priority Critical patent/CN111722849B/en
Publication of CN111722849A publication Critical patent/CN111722849A/en
Application granted granted Critical
Publication of CN111722849B publication Critical patent/CN111722849B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a JAVA language virtual compiling realization method, a system and a device, wherein the method comprises the following steps: converting the general java class content into a virtual class file; and loading java class and virtual class files. By adopting the embodiment of the invention, in the specific compiling field of the source code without considering the running time of the java programming language, the compiling efficiency is improved by simplifying the specific content implementation in the reference class file, and the volume of the reference class file is reduced, so that the performance burden, the storage burden and the transmission burden of the compiling environment are reduced.

Description

JAVA language virtual compiling realization method, system and device
Technical Field
The invention relates to the technical field of computers, in particular to a JAVA language virtual compiling realization method, system and device.
Background
The java language is used as a strong type compiling language, and in the compiling process of each item, the compiling work can be completed by loading and declarative checking the actual class file (class) corresponding to the reference type in the source code. The reference class (class) compiled by java must exist in a file form in the project environment in order to be compiled and loaded by a compiler and then loaded to a virtual machine for operation.
With the increasing demands of different compiling scenes of source codes and the popularization of related technologies, compiling is taken as a means for processing the source codes and is not limited to a general application flow for generating a final execution program; source code security inspection, source code specification inspection, source code component analysis and the like are taken as expansion scenes of compiling requirements, and the compiling technology is embodied everywhere as functional independence for constructing specific products.
Therefore, how to improve the compiling efficiency and reduce the volume of the reference class file, thereby reducing the performance burden, the storage burden and the transmission burden of the compiling environment is a technical problem that needs to be solved at present.
Disclosure of Invention
The invention aims to provide a JAVA language virtual compiling realization method, system and device, and aims to solve the problems in the prior art.
The invention provides a JAVA language virtual compiling realization method, which comprises the following steps:
converting the general java class content into a virtual class file;
and loading java class and virtual class files.
The invention provides a JAVA language virtual compiling realization system, which comprises:
the conversion module is used for converting the general java class content into a virtual class file;
And the loading module is used for loading java class and virtual class files.
The embodiment of the invention also provides a JAVA language virtual compiling device, which comprises: the JAVA language virtual compiling method comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, wherein the computer program realizes the steps of the JAVA language virtual compiling method when being executed by the processor.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores an information transmission implementation program, and the program realizes the steps of the JAVA language virtual compiling implementation method when being executed by a processor.
By adopting the embodiment of the invention, in the specific compiling field of the source code without considering the running time of the java programming language, the compiling efficiency is improved by simplifying the specific content implementation in the reference class file, and the volume of the reference class file is reduced, so that the performance burden, the storage burden and the transmission burden of the compiling environment are reduced.
The foregoing description is only an overview of the present invention, and is intended to be implemented in accordance with the teachings of the present invention in order that the same may be more clearly understood and to make the same and other objects, features and advantages of the present invention more readily apparent.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a JAVA language virtual compilation implementation method according to an embodiment of the present invention;
FIG. 2 is a flow chart of converting general java class content into a virtual class file according to an embodiment of the present invention;
FIG. 3 is a flow chart of the loading of java class and virtual class files according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a JAVA language virtual compilation implementation system of an embodiment of the present invention;
Fig. 5 is a schematic diagram of a JAVA language virtual compilation implementing apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention will be clearly and completely described in connection with the embodiments, and it is apparent that the described embodiments are some embodiments of the present invention, but 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.
In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings are merely for convenience in describing the present invention and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific orientation, be configured and operated in a specific orientation, and thus should not be construed as limiting the present invention.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more of the described features. In the description of the present invention, the meaning of "a plurality" is two or more, unless explicitly defined otherwise. Furthermore, the terms "mounted," "connected," "coupled," and "connected" are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communication between two elements. The specific meaning of the above terms in the present invention will be understood in specific cases by those of ordinary skill in the art.
Method embodiment
Class files of the java programming language (class), in the process of the applicant implementing the invention, are considered to be mainly composed of two parts of content: 1. the declaration part comprises the description of the information of the class and the internal and external classes, the declaration of the attribute of the class, the declaration of the method of the class and the like, and is used for carrying out type inspection on the content referencing the declaration of the class in the compiling process of the source code. 2. Specific logic content implementation in the class comprises static logic blocks, attribute assignment expressions, method specific content implementation and the like in the class.
Through research on compiling technology, the compiling process is mainly divided into three stages, namely: lexical analysis, grammatical analysis, and semantic analysis. Lexical and grammatical analysis is basically performed around the source code, and the goal is to generate a tree-like grammar data structure from the source code; semantic analysis makes type definition on grammatically referenced contents by referring to declaration information in classes based on grammar data structure. If the type of the non-basic type in the code is used, an explicit source is needed, and the use of the external reference method is needed to determine the declaration details thereof. In the reference file-class file required by the semantic analysis process, only the declaration part in the class is used, and the specific logic implementation content does not need to be referenced in compiling, and is functionally implemented as the runtime of the software project.
In summary, by deleting specific functional logic content in the reference class file, declaration information is reserved to reduce the size of the reference class file, and the performance requirement burden, disk storage burden and file transmission burden of the source code in the execution of the compiling step are reduced as much as possible while the specific compiling scene process is ensured to be supported.
According to an embodiment of the present invention, a JAVA language virtual compilation implementation method is provided, and fig. 1 is a flowchart of the JAVA language virtual compilation implementation method according to the embodiment of the present invention, as shown in fig. 1, the JAVA language virtual compilation implementation method according to the embodiment of the present invention specifically includes:
Step 301, converting general java class content into a virtual class file; step 301 specifically includes:
loading java class files as object data, and creating corresponding virtual class files;
Reading the current class declaration information, and writing the current class declaration information into the virtual class file; the main content acting on compiling support in the current class declaration information comprises: generating a java compiler version, a modifier, a current class parent class description, current class signature information and an interface list to be realized by the current class of the current class file;
if the internal class exists, reading the internal class declaration information, and writing the internal class declaration information into the virtual class file; wherein the internal class declaration information includes: an internal class name, an inherited parent class description, an external class description thereof, internal class signature information, and an interface list of implementations;
The java class attribute is read, and the java class attribute is written into the virtual class file; the java class attribute comprises: and the modifier and the type description, wherein the assignment part determines whether the assignment part is included according to the requirements of the compiling scene.
And reading the class method and writing the class method into the virtual class file, wherein the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and exception type list thrown.
Step 302, loading java class and virtual class files.
Step 302 specifically includes the following processing:
Step 1, judging whether a native java class file or a virtual class file is loaded, if the native java class file is judged, executing step 3, and if the virtual class file is judged, executing step 2;
Step 2, adopting a custom virtual class loader, carrying out flow reverse processing according to the data writing process of the virtual class file to obtain various declaration information in the original java class, re-assembling the various declaration information of the class file into a java class object, and loading the java class object into a class declaration cache as the objection data of the java class for the semantic analysis program in the subsequent compiling step;
And step 3, adopting a default java class loader to completely read the declaration information and specific function realization content in the java class file, and loading the declaration information and specific function realization content as the objectified data of one java class into a class declaration cache for the semantic analysis program in the subsequent compiling step.
The above technical solutions of the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
Step 1, converting general java class content into a virtual class file, wherein the specific processing is as shown in fig. 2:
Corresponding to the general java class reference file, selective content processing is carried out, and the processed virtual class file can define the name and format by user, so that the aim is to simplify the content of idle work in the compiling process in the java class.
Step 101, loading Java class files (the target data loaded is Java. Lang. Class objects or ASM ClassNode objects, etc., which are not described here as open source technology), as object data to facilitate the subsequent content reading step.
Step 111, after the step 101 is successfully executed, a corresponding virtual class file is created, various declaration information with the content of the original java class is written in the virtual class file, the writing format is not particularly required, the virtual class file name is written in a text form in the example step, the virtual class file name is named by referring to a source class file name, and the suffix ". Class" is changed into ". Zip.class" to distinguish the source class file.
Step 102 reads the current class declaration, whose main content acting on compilation support consists of: a java compiler version of the current class file, a modifier, a current class parent description, current class Signature information (Signature), and an Interface (Interface) list to be implemented by the current class are generated.
Step 112, for the current class declaration read at 102, writing the content into the virtual class file in a custom format, in this example step, writing of the current class declaration information, defined as row 1, the various parts of the declaration information are separated by commas, wherein a space separation is used between each sub-content of the Interface (Interface) list.
Step 103, if the internal class exists, the internal class declaration needs to be read, including the internal class name, the inherited parent class description, the external class description, the internal class Signature information (Signature), and the Interface (Interface) list of the implementation, and if the internal class does not need to be used as source code compiling support, the content in the internal class is directly abandoned.
Step 113, the above internal class declaration is written into the virtual class file as the necessary information for compiling the source code; the write format is defined as line 2, with parts of the internal class declaration being separated by commas when written sequentially, with one space separation between each sub-content of the Interface (Interface) list, and multiple internal classes separated by semicolons.
And 104, reading the java class attribute, wherein the content of the java class attribute comprises modifiers and type descriptions, and the assignment part is used for determining whether to read or not by considering the requirements of compiling the scene.
Step 114, writing the content read in step 104 into the virtual class file, writing behavior 3, and separating each part of the attribute declaration by comma when writing data, wherein a plurality of attributes are separated by semicolons.
Step 105, a class method is read, the content of which includes a method Signature (Signature), a modifier, a return value type, a method name, a parameter type list, and a thrown exception type list.
In step 115, the above content is written into the virtual class file, and in step 4, the writing format in the implementation step may refer to the class attribute, and separate the information parts of the method statement by comma, where a space separation is used between each sub-content of the method parameter type list and the thrown exception type list, and a number separation is used between the method statements.
And 106, the java class loader loads the next java class file as required, and repeats the processes 101-105 to read the content, and generates a new virtual class file corresponding to the java class loading 111-115.
According to the processing scheme, the user-defined virtual class file is generated by reserving the declaration information necessary for compiling in the java class file, and the aim of slimming the source code dependent class file is fulfilled. Through preliminary tests, compared with java class files, the storage space consumed by the same corresponding virtual class is less than 50%, namely, the java class files with the size of 10MB are processed into the virtual class files, the file size is within 5MB, the disk use space is obviously saved in the slimming step, and the transmission speed of the dependent files in the source code compiling process is improved.
Step 2, loading processes of java class and virtual class files, wherein specific processes are shown in fig. 3:
step 201, applied to a specific compiling scene, class loading in the step of the embodiment of the present invention can support two file forms; a native java class file (class) is compiled and generated by a compiler of the java itself and is applied to a general compiling flow of the existing product. The other is a virtual class file (.zip.class) generated by the method, and the file only faces to the requirement of a source code compiling step and only contains various declaration information in java classes.
In a specific compiling scenario modified using an embodiment of the present invention, step 202, it is quickly determined whether a class file is a virtual class by creating a check condition, i.e., checking the suffix of the class file name. If in the method, the virtual class is loaded by judging that the "zip. Class" file name suffix is TRUE, i.e. the condition TRUE is satisfied, the program flow goes to step 203; the native java class file name is terminated with a class suffix, conditional FALSE, and program execution branches to step 204.
And 203, the program performs flow reversal to acquire various declaration information in the original java class through the data writing process of the virtual class file. If the class declaration character string is generated by reading the line 1 in the step, the parts of declaration information in the character string are split through commas to form the array data, and for the array data, specific declaration content is read according to the subscript in the step processing, wherein the subscript 0 is a compiler version number, the subscript 1 is a current class Signature (Signature), and the subscript 2 is an interface list of the current class implementation. In the above, the interface list is further split by using a space as a whole of a character string, so as to obtain specific names of each interface, which are used for accurately restoring java object data. Other content acquisition modes in the virtual class are similar to the class declaration information, such as zero or more cases exist in the internal class, class attribute and class method. Taking the internal class as an example, when the internal class does not exist, the virtual class file line 2 is empty, the internal class information is read to determine whether the internal class exists or not according to the obtained character string length, and when a plurality of internal classes exist, the unit splitting can be performed through the division number.
Through the operation steps, various declaration data of the class file is reassembled into the java class object. At source code compilation time, the objectified data is stored in a class declaration cache, step 205, for use by the semantic analysis program in subsequent compilation steps.
In step 204, a default java class loader is adopted, the loaded class must be complete, and the class file must be generated through java compiling, otherwise, the loading failure of class will be caused by the content reading rule according to the default logic, and the compiling failure is caused by the semantic analysis to the current source file. In this step, the declaration information and the specific function implementation content in the java class file are completely read, and as the objectified data of a java class, the class object is loaded into the class declaration cache in the next step, that is, step 205, while in the subsequent semantic analysis step, the specific function logic content is not read and plays any substantial role except for various declaration information.
Step 205, caching java class object data.
From the above-mentioned processing, the implementation of step 2 is simpler by means of step 1, the influence on the original program compiling process is very small, and by loading the simplified virtual class file, the reading of invalid content is avoided, and the class loading speed is effectively improved. In addition, in the step 2, the default class loader in the existing compiling step is reserved, and in the compiling process, both the two loaders 203 and 204 can be started to work according to the judging condition 202 without mutual influence, and in the step 205, the java class objectified data which is loaded completely is loaded, although the content is slightly different, the declaration structure information is consistent, and in the subsequent semantic analysis process, the difference is not generated, and the method also provides a reliable solution for considering the general java class loading, the general java class and the virtual class mixed loading. In a specific compiling scene, the loading implementation of the virtual class method can greatly improve the loading speed and obviously save the computer performance corresponding to the loading requirements of a large number of source code dependent classes.
In summary, by means of the technical scheme provided by the embodiment of the invention, the method has the following beneficial effects:
1. The content of the java class file is simplified, the volume of the source code reference file can be effectively reduced by the created virtual class file, the disk storage space is effectively saved under the condition of ensuring the specific compiling scene requirement of the source code, and the time loss of the source code dependent file in the transmission process is saved.
2. The method provides a set of specific implementation steps for simplifying the content of the java file, and by referring to the steps, developers can conveniently and rapidly realize the function in the product.
3. The method has the advantages that the content of the source code reference class file is selectively simplified, the loading efficiency of java class objects in the compiling process is improved, and the compiling speed of the source code can be remarkably improved.
4. For the compiling implementation step in the existing product, the class loader in the compiling step can quickly identify the virtual class by carrying out tiny improvement on the program, so that the influence of the custom loading flow on the original java class loader is avoided.
5. Virtual class file and class loader with custom content format, providing play space for realizing compiling requirement of specific scene
6. The collaborative work of the custom class loader and the default class loader is supported through simple judging conditions, the processing of the java class file in the original compiling step is completely considered, and a perfect solution is provided for the mixed loading of the java class and the virtual class.
System embodiment
According to an embodiment of the present invention, a JAVA language virtual compilation implementation system is provided, and fig. 4 is a schematic diagram of the JAVA language virtual compilation implementation system according to the embodiment of the present invention, as shown in fig. 4, where the JAVA language virtual compilation implementation system according to the embodiment of the present invention specifically includes:
the conversion module 40 is used for converting the general java class content into a virtual class file; the conversion module 40 is specifically configured to:
loading java class files as object data, and creating corresponding virtual class files;
Reading the current class declaration information, and writing the current class declaration information into the virtual class file; the main content acting on compiling support in the current class declaration information comprises: generating a java compiler version, a modifier, a current class parent class description, current class signature information and an interface list to be realized by the current class of the current class file;
if the internal class exists, reading the internal class declaration information, and writing the internal class declaration information into the virtual class file; wherein the internal class declaration information includes: an internal class name, an inherited parent class description, an external class description thereof, internal class signature information, and an interface list of implementations;
The java class attribute is read, and the java class attribute is written into the virtual class file; the java class attribute comprises: and the modifier and the type description, wherein the assignment part determines whether the assignment part is included according to the requirements of the compiling scene.
And reading the class method and writing the class method into the virtual class file, wherein the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and exception type list thrown.
And the loading module 42 is used for loading java class and virtual class files. The loading module 42 specifically includes:
The judging submodule is used for judging whether the loaded native java class file or the virtual class file, calling a default java class loader if the loaded native java class file is judged, and calling a custom virtual class loader if the loaded native java class file is judged to be the virtual class file;
The customized virtual class loader is used for carrying out flow reverse processing according to the data writing process of the virtual class file to obtain various declaration information in the original java class, re-assembling the various declaration information of the class file into a java class object, and loading the java class object into a class declaration cache as the objection data of the java class for the semantic analysis program in the subsequent compiling step;
The default java class loader is used for completely reading the declaration information and the specific function realization content in the java class file, and is used as the objectified data of the java class to be loaded into the class declaration cache for the semantic analysis program in the subsequent compiling step.
The embodiment of the present invention is a system embodiment corresponding to the above method embodiment, and specific operations of each module may be understood by referring to the description of the method embodiment, which is not repeated herein.
Device embodiment 1
The embodiment of the invention provides a JAVA language virtual compiling realization device, as shown in fig. 5, comprising: a memory 50, a processor 52 and a computer program stored on the memory 50 and executable on the processor 52, which when executed by the processor 52 performs the following method steps:
Step 301, converting general java class content into a virtual class file; step 301 specifically includes:
loading java class files as object data, and creating corresponding virtual class files;
Reading the current class declaration information, and writing the current class declaration information into the virtual class file; the main content acting on compiling support in the current class declaration information comprises: generating a java compiler version, a modifier, a current class parent class description, current class signature information and an interface list to be realized by the current class of the current class file;
if the internal class exists, reading the internal class declaration information, and writing the internal class declaration information into the virtual class file; wherein the internal class declaration information includes: an internal class name, an inherited parent class description, an external class description thereof, internal class signature information, and an interface list of implementations;
The java class attribute is read, and the java class attribute is written into the virtual class file; the java class attribute comprises: and the modifier and the type description, wherein the assignment part determines whether the assignment part is included according to the requirements of the compiling scene.
And reading the class method and writing the class method into the virtual class file, wherein the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and exception type list thrown.
Step 302, loading java class and virtual class files.
Step 302 specifically includes the following processing:
Step 1, judging whether a native java class file or a virtual class file is loaded, if the native java class file is judged, executing step 3, and if the virtual class file is judged, executing step 2;
Step 2, adopting a custom virtual class loader, carrying out flow reverse processing according to the data writing process of the virtual class file to obtain various declaration information in the original java class, re-assembling the various declaration information of the class file into a java class object, and loading the java class object into a class declaration cache as the objection data of the java class for the semantic analysis program in the subsequent compiling step;
And step 3, adopting a default java class loader to completely read the declaration information and specific function realization content in the java class file, and loading the declaration information and specific function realization content as the objectified data of one java class into a class declaration cache for the semantic analysis program in the subsequent compiling step.
Device example two
An embodiment of the present invention provides a computer-readable storage medium having stored thereon a program for realizing information transmission, which when executed by the processor 52 realizes the following method steps:
Step 301, converting general java class content into a virtual class file; step 301 specifically includes:
loading java class files as object data, and creating corresponding virtual class files;
Reading the current class declaration information, and writing the current class declaration information into the virtual class file; the main content acting on compiling support in the current class declaration information comprises: generating a java compiler version, a modifier, a current class parent class description, current class signature information and an interface list to be realized by the current class of the current class file;
if the internal class exists, reading the internal class declaration information, and writing the internal class declaration information into the virtual class file; wherein the internal class declaration information includes: an internal class name, an inherited parent class description, an external class description thereof, internal class signature information, and an interface list of implementations;
The java class attribute is read, and the java class attribute is written into the virtual class file; the java class attribute comprises: and the modifier and the type description, wherein the assignment part determines whether the assignment part is included according to the requirements of the compiling scene.
And reading the class method and writing the class method into the virtual class file, wherein the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and exception type list thrown.
Step 302, loading java class and virtual class files.
Step 302 specifically includes the following processing:
Step 1, judging whether a native java class file or a virtual class file is loaded, if the native java class file is judged, executing step 3, and if the virtual class file is judged, executing step 2;
Step 2, adopting a custom virtual class loader, carrying out flow reverse processing according to the data writing process of the virtual class file to obtain various declaration information in the original java class, re-assembling the various declaration information of the class file into a java class object, and loading the java class object into a class declaration cache as the objection data of the java class for the semantic analysis program in the subsequent compiling step;
And step 3, adopting a default java class loader to completely read the declaration information and specific function realization content in the java class file, and loading the declaration information and specific function realization content as the objectified data of one java class into a class declaration cache for the semantic analysis program in the subsequent compiling step.
In summary, by means of the technical scheme provided by the embodiment of the invention, the method has the following beneficial effects:
1. The content of the java class file is simplified, the volume of the source code reference file can be effectively reduced by the created virtual class file, the disk storage space is effectively saved under the condition of ensuring the specific compiling scene requirement of the source code, and the time loss of the source code dependent file in the transmission process is saved.
2. The method provides a set of specific implementation steps for simplifying the content of the java file, and by referring to the steps, developers can conveniently and rapidly realize the function in the product.
3. The method has the advantages that the content of the source code reference class file is selectively simplified, the loading efficiency of java class objects in the compiling process is improved, and the compiling speed of the source code can be remarkably improved.
4. For the compiling implementation step in the existing product, the class loader in the compiling step can quickly identify the virtual class by carrying out tiny improvement on the program, so that the influence of the custom loading flow on the original java class loader is avoided.
5. Virtual class file and class loader with custom content format, providing play space for realizing compiling requirement of specific scene
6. The collaborative work of the custom class loader and the default class loader is supported through simple judging conditions, the processing of the java class file in the original compiling step is completely considered, and a perfect solution is provided for the mixed loading of the java class and the virtual class.
The computer readable storage medium of the present embodiment includes, but is not limited to: ROM, RAM, magnetic or optical disks, etc.
It will be appreciated by those skilled in the art that the modules or steps of the invention described above may be implemented in a general purpose computing device, they may be concentrated on a single computing device, or distributed across a network of computing devices, they may alternatively be implemented in program code executable by computing devices, so that they may be stored in a memory device for execution by computing devices, and in some cases, the steps shown or described may be performed in a different order than that shown or described, or they may be separately fabricated into individual integrated circuit modules, or multiple modules or steps within them may be fabricated into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.

Claims (6)

1. The JAVA language virtual compiling implementation method is characterized by comprising the following steps:
the converting the general java class content into the virtual class file specifically comprises the following steps:
loading java class files as object data, and creating corresponding virtual class files;
reading current class declaration information, and writing the current class declaration information into the virtual class file;
If the internal class exists, reading the internal class declaration information, and writing the internal class declaration information into the virtual class file;
Reading java class attributes, and writing the java class attributes into the virtual class file;
reading a class method, and writing the class method into the virtual class file;
the loading of java class and virtual class files specifically comprises:
step 1, judging whether the loaded native java class file or the virtual class file, if the loaded native java class file is judged, executing step 3, and if the loaded native java class file is judged to be the virtual class file, executing step 2;
step 2, adopting a custom virtual class loader, carrying out flow reverse processing according to the data writing process of the virtual class file to obtain various declaration information in the original java class, re-assembling the various declaration information of the class file into a java class object, and loading the java class object into a class declaration cache as objectified data of the java class for use by a semantic analysis program in a subsequent compiling step;
And step 3, adopting a default java class loader to completely read the declaration information and specific function realization content in the java class file, and loading the declaration information and specific function realization content as the objectified data of one java class into a class declaration cache for the semantic analysis program in the subsequent compiling step.
2. The method of claim 1, wherein the step of determining the position of the substrate comprises,
The main content acting on compiling support in the current class declaration information comprises: generating a java compiler version, a modifier, a current class parent class description, current class signature information and an interface list to be realized by the current class of the current class file;
the internal class declaration information includes: an internal class name, an inherited parent class description, an external class description thereof, internal class signature information, and an interface list of implementations;
The java class attribute comprises: a modifier and a type description, wherein the assignment portion determines whether to include according to requirements of the compiled scene;
the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and exception type list thrown.
3. A JAVA language virtual compilation implementation system, comprising:
The conversion module is used for converting the general java class content into a virtual class file; the method is particularly used for:
loading java class files as object data, and creating corresponding virtual class files;
reading current class declaration information, and writing the current class declaration information into the virtual class file;
If the internal class exists, reading the internal class declaration information, and writing the internal class declaration information into the virtual class file;
Reading java class attributes, and writing the java class attributes into the virtual class file;
reading a class method, and writing the class method into the virtual class file;
the loading module is used for loading java class and virtual class files; the method specifically comprises the following steps:
The judging submodule is used for judging whether the loaded native java class file or the virtual class file, calling a default java class loader if the loaded native java class file is judged, and calling a custom virtual class loader if the loaded native java class file is judged to be the virtual class file;
The customized virtual class loader is used for carrying out flow reverse processing according to the data writing process of the virtual class file to obtain various declaration information in the original java class, re-assembling the various declaration information of the class file into a java class object, and loading the java class object into a class declaration cache as the objection data of the java class for the semantic analysis program in the subsequent compiling step;
The default java class loader is used for completely reading the declaration information and the specific function realization content in the java class file, and is used as the objectified data of the java class to be loaded into the class declaration cache for the semantic analysis program in the subsequent compiling step.
4. The system of claim 3, wherein the system further comprises a controller configured to control the controller,
The main content acting on compiling support in the current class declaration information comprises: generating a java compiler version, a modifier, a current class parent class description, current class signature information and an interface list to be realized by the current class of the current class file;
the internal class declaration information includes: an internal class name, an inherited parent class description, an external class description thereof, internal class signature information, and an interface list of implementations;
The java class attribute comprises: a modifier and a type description, wherein the assignment portion determines whether to include according to requirements of the compiled scene;
the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and exception type list thrown.
5. A JAVA language virtual compilation implementation apparatus, comprising: memory, a processor and a computer program stored on the memory and executable on the processor, which when executed by the processor, performs the steps of the JAVA language virtual compilation implementation method according to any of claims 1 to 2.
6. A computer-readable storage medium, wherein a program for realizing information transfer is stored on the computer-readable storage medium, and the program when executed by a processor realizes the steps of the JAVA language virtual compilation realizing method according to any one of claims 1 to 2.
CN202010692748.8A 2020-07-17 2020-07-17 JAVA language virtual compiling realization method, system and device Active CN111722849B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010692748.8A CN111722849B (en) 2020-07-17 2020-07-17 JAVA language virtual compiling realization method, system and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010692748.8A CN111722849B (en) 2020-07-17 2020-07-17 JAVA language virtual compiling realization method, system and device

Publications (2)

Publication Number Publication Date
CN111722849A CN111722849A (en) 2020-09-29
CN111722849B true CN111722849B (en) 2024-06-25

Family

ID=72572808

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010692748.8A Active CN111722849B (en) 2020-07-17 2020-07-17 JAVA language virtual compiling realization method, system and device

Country Status (1)

Country Link
CN (1) CN111722849B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342419B (en) * 2021-06-25 2023-09-19 北京奇艺世纪科技有限公司 Push system loading method and device, electronic equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110162306A (en) * 2018-02-14 2019-08-23 阿里巴巴集团控股有限公司 The just-ahead-of-time compilation method and apparatus of system
KR20200046499A (en) * 2018-10-24 2020-05-07 삼성에스디에스 주식회사 Apparatus and method for compiling partial source code

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101968736A (en) * 2010-09-13 2011-02-09 杭州元睿信息技术有限公司 Translation method for applying Java to external reference in C++ language program translation
WO2015148424A1 (en) * 2014-03-27 2015-10-01 Microsoft Technology Licensing, Llc Supporting dynamic behavior in statically compiled programs
US10296313B2 (en) * 2014-11-18 2019-05-21 Roger James Poon Safely consuming dynamically-typed code from a statically-typed programming language
CN104503816B (en) * 2014-12-30 2017-09-19 西安电子科技大学 A kind of hardware language VHDL to MSVL automated conversion system
US9684492B2 (en) * 2015-09-28 2017-06-20 Semmle Limited Automatic determination of compiler configuration
CN109976760A (en) * 2017-12-27 2019-07-05 北京东土科技股份有限公司 A kind of the cross compile method and cross-compiler of graphic language
CN109992259B (en) * 2019-04-15 2020-10-30 成都四方伟业软件股份有限公司 Function dynamic creating method and device and electronic equipment
CN110825384A (en) * 2019-10-28 2020-02-21 国电南瑞科技股份有限公司 ST language compiling method, system and compiler based on LLVM

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110162306A (en) * 2018-02-14 2019-08-23 阿里巴巴集团控股有限公司 The just-ahead-of-time compilation method and apparatus of system
KR20200046499A (en) * 2018-10-24 2020-05-07 삼성에스디에스 주식회사 Apparatus and method for compiling partial source code

Also Published As

Publication number Publication date
CN111722849A (en) 2020-09-29

Similar Documents

Publication Publication Date Title
JP4183399B2 (en) Multiple language compilation method and system
US5586328A (en) Module dependency based incremental compiler and method
CN1134731C (en) Technology of reducing cost of primary examination to dynamic kinds in compiled codes
US7013458B2 (en) Method and apparatus for associating metadata attributes with program elements
US9892144B2 (en) Methods for in-place access of serialized data
US8201143B2 (en) Dynamic mating of a modified user interface with pre-modified user interface code library
US8549502B2 (en) Compiler with user-defined type inference rules
US20090313604A1 (en) Parsing of declarations in all branches of preprocessor conditionals
CN110990019B (en) Java class analysis method and device, storage medium and electronic equipment
CN103999036A (en) Method and system using exceptions for code specialization in a computer architecture that supports transactions
CN113296786B (en) Data processing method, device, electronic equipment and storage medium
CN111722849B (en) JAVA language virtual compiling realization method, system and device
CN113900657A (en) Method for reading data rule, electronic device and storage medium
CN111435312A (en) Application program management method and device and electronic equipment
US6427231B1 (en) System and method for multiple entry point access to an object
CN111782212A (en) View assembly creating method and device and storage medium
CN1287280C (en) Method for increasing executing characteristic of function while operation, and calulating system thereof
JP2006107339A (en) Program processor
CN114911541A (en) Configuration information processing method and device, electronic equipment and storage medium
JP3049814B2 (en) Microcomputer language processor
CN111767033A (en) Programming system for mechanical arm program development and function extension method
JP2017091070A (en) Executable code generation program and executable code generation device
CN114579135B (en) Installation package generation method and device
CN114489683B (en) JVM-based functional programming grammar implementation method for java-like language
US20080307446A1 (en) Interoperable Managed and Unmanaged Code in a Document Environment

Legal Events

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