CN111722849A - Method, system and device for realizing virtual compiling of JAVA language - Google Patents

Method, system and device for realizing virtual compiling of JAVA language Download PDF

Info

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

Links

Images

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 method, a system and a device for realizing JAVA language virtual compilation, wherein the method comprises the following steps: converting the general java class content into a virtual class file; and loading the java class and the virtual class file. 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 in the reference file, and the volume of the reference file is reduced, so that the performance burden, the storage burden and the transmission burden of the compiling environment are reduced.

Description

Method, system and device for realizing virtual compiling of JAVA language
Technical Field
The invention relates to the technical field of computers, in particular to a method, a system and a device for realizing virtual compilation of a JAVA language.
Background
The java language is a strong type compiling language, and in the compiling process of each item, the actual class file (. class) corresponding to the reference type in the source code must be loaded and subjected to declaration inspection to complete the compiling work. The quote class (class) compiled by java is required to exist in a file form in a project environment, and can be compiled and loaded by a compiler and then loaded to a virtual machine for running.
With the increasing enhancement of different compiling scene requirements of source codes and the popularization of related technologies, compiling is not limited to a general application process for generating a final execution program as a means for processing the source codes; the source code safety inspection, the source code standard inspection, the source code component analysis and the like are used as an expansion scene of the compiling requirement, and the compiling technology is embodied everywhere as the functional independence for constructing a specific product.
Therefore, how to improve the compiling efficiency and reduce the volume of the reference file so as to reduce the performance burden, the storage burden and the transmission burden of the compiling environment is a technical problem to be solved urgently at present.
Disclosure of Invention
The invention aims to provide a method, a system and a device for realizing virtual compilation of a JAVA language, and aims to solve the problems in the prior art.
The invention provides a method for realizing virtual compilation of a JAVA language, which comprises the following steps:
converting the general java class content into a virtual class file;
and loading the java class and the virtual class file.
The invention provides a JAVA language virtual compiling implementation system, which comprises:
the conversion module is used for converting the general java class contents into virtual class files;
and the loading module is used for loading the java class and the virtual class file.
An embodiment of the present invention further provides a JAVA language virtual compilation implementing apparatus, including: the JAVA language virtual compiling implementation method comprises the following steps of a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein when the computer program is executed by the processor, the steps of the JAVA language virtual compiling implementation method are realized.
The embodiment of the invention also provides a computer readable storage medium, wherein an implementation program for information transmission is stored on the computer readable storage medium, 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 in the reference file, and the volume of the reference 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 technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow chart of a method for implementing virtual compilation of a JAVA language according to an embodiment of the present invention;
FIG. 2 is a flowchart of converting general java class content into a virtual class file according to an embodiment of the present invention;
FIG. 3 is a flowchart of loading java class and virtual class files according to an embodiment of the present invention;
FIG. 4 is a diagram of a JAVA language virtual compilation implementation system according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a JAVA language virtual compilation implementation apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the following embodiments, and it should be understood that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the present invention, it is to be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", and the like, indicate orientations and positional relationships based on those shown in the drawings, and are used only for convenience of description and simplicity of description, and do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be considered as limiting the present invention.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first", "second", may explicitly or implicitly include one or more of the described features. In the description of the present invention, "a plurality" means two or more unless specifically defined otherwise. Furthermore, the terms "mounted," "connected," and "connected" are to be construed broadly and may, for example, be fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
Method embodiment
Class file (. class) of java programming language, which is considered to be mainly composed of two parts in the process of implementing the invention by the applicant: 1. the declaration part comprises the type, internal and external type information description, type attribute declaration, type method declaration and the like, and is used for supporting type check on the content of the quoting type declaration in the source code compiling process. 2. The specific logic content implementation in the class comprises a static logic block in the class, an attribute assignment expression, method specific content implementation and the like.
Through research on compiling technology, the compiling process is mainly divided into three stages, namely: lexical analysis, syntactic analysis, and semantic analysis. Lexical and syntactic analyses are basically performed around a source code, and the target is to generate a tree-shaped syntactic data structure from the source code; semantic analysis is based on a syntactic data structure, and the types of the syntactic citation contents are made clear by quoting the declaration information in the class. If the type usage of non-base types in the code requires an explicit source, the use of external reference methods requires the determination of its declaration details. The reference file, class file, required by the semantic analysis process only uses the declaration part in the class, and the specific logic implementation content does not need to be referenced in the compilation and is implemented as the function of the software project running time.
In summary, the size of the reference file is reduced by deleting the specific functional logic content in the reference file and retaining the declaration information, so that the performance requirement burden, the disk storage burden and the file transmission burden of the source code in the compiling execution step are reduced as much as possible while the specific compiling scene process is supported.
According to an embodiment of the present invention, a JAVA language virtual compilation implementation method is provided, fig. 1 is a flowchart of the JAVA language virtual compilation implementation method according to the embodiment of the present invention, and 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 the general java content into a virtual file; step 301 specifically includes:
loading the java class files into objectified data, and creating corresponding virtual class files;
reading current class declaration information, and writing the current class declaration information into a virtual class file; the main contents of the current class declaration information, which are used for compiling support, include: 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 inner class declaration information includes: an internal class name, an inherited parent class description, its external class description, internal class signature information, and an implemented interface list;
reading the java class attribute, and writing the java class attribute into the virtual class file; the java class attribute comprises: a modifier and a type description, wherein the assignment part determines whether to include according to the requirements of the compilation scenario.
Reading a class method, and writing the class method into a virtual class file, wherein the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and thrown exception type list.
Step 302, loading java class and virtual class files.
Step 302 specifically includes the following processing:
step 1, judging whether a loaded native java file or a virtual file is a native java file, if the loaded native java file is judged to be the native java file, executing step 3, and if the loaded native java file is judged to be the virtual file, executing step 2;
step 2, adopting a user-defined virtual class loader, performing flow reverse processing according to the data writing process of the virtual class file to obtain various types of declaration information in the original java class, reassembling the various types of declaration information of the class file into a java class object, and loading the java class object as java class objectified data into a class declaration cache for a semantic analysis program in a subsequent compiling step;
and 3, adopting a default java class loader to completely read the statement information and the specific function realization content in the java class file, and loading the statement information and the specific function realization content as object data of the java class into a class statement cache for a semantic analysis program in a 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 the general java class content into a virtual class file, and specifically processing the virtual class file as shown in fig. 2:
corresponding to the general java class reference file, selective content processing is carried out, the name and the format of the processed virtual class file can be defined by users, and the purpose is to simplify the useless content in the java class in the compiling process.
Step 101, loading Java class files (the loaded target data includes Java integrated Java, lang, class objects or ASM class node objects, etc., and the data objectification method is used as an open source technology and is not described here), and loading the Java class files into objectification data to facilitate the subsequent content reading step.
Step 111, after the step 101 is successfully executed, a corresponding virtual class file is created, and then various declaration information with the content of the original java class is written in the subsequent step, the writing format has no special requirement, in the step of this example, the virtual class file is written in a text form, the name of the virtual class file refers to the name of the source class file, and the suffix ". class" is changed to ". zip.
Step 102 reads the current class declaration, whose main contents acting on the compilation support are composed of the following parts: and generating a java compiler version, a modifier, a current class parent class description, current class Signature information (Signature) and an Interface (Interface) list to be realized by the current class of the current class file.
Step 112, writing the content into the virtual class file in a custom format for the current class declaration read by 102, in this example step, the writing of the current class declaration information is defined as line 1, and the parts of the declaration information are separated by commas, where each sub-content of the Interface (Interface) list is separated by a space.
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 thereof, the internal class Signature information (Signature), and the realized Interface (Interface) list, and the content in the internal class is directly discarded if the internal class does not need to be used as the source code compiling support.
Step 113, the 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 row 2, with portions of the inner class declaration being sequentially written separated by commas, with each sub-content of the Interface (Interface) list separated by a space, and multiple inner classes separated by semicolons.
Step 104, reading java class attributes, wherein the content of the java class attributes comprises modifiers and type descriptions, and the assignment part memory determines whether to read or not by considering the requirements of a compiling scene.
And step 114, writing the content read in the step 104 into the virtual class file, writing the behavior 3, wherein the parts of the attribute declaration are separated by commas when the data is written, and the multiple attributes are separated by semicolons.
Step 105, reading class methods, wherein the content of the class methods comprises method signatures (Signature), modifiers, return value types, method names, parameter type lists and thrown exception type lists.
Step 115, writing the content into a virtual class file, and writing into action 4, wherein in the implementation step, the writing format can refer to class attributes, and the information parts are declared by comma separation methods, wherein each sub-content of the method parameter type list and the thrown exception type list is separated by a space, and a plurality of method declarations are separated by semicolons.
Step 106, the java class loader loads the next java class file as required, the process 101-105 is repeated to read the content, and 111-115 corresponding to the java class loading generates a new virtual class file.
The processing scheme generates a self-defined virtual class file by reserving the necessary statement information compiled in the java class file, and realizes the aim of 'slimming' the source code dependent class file. Through preliminary tests, the same corresponding virtual class consumes less than 50% of storage space compared with the java class file, namely the java class file with the size of 10MB is processed into the virtual class file, the size of the file is within 5MB, the step of slimming obviously saves the use space of a disk, and the transmission speed of the dependent file in the source code compiling process is improved.
Step 2, a loading flow of java class and virtual class files, specifically processing is as shown in fig. 3:
step 201, applied to a specific compiling scenario, the class loading in the steps of the embodiment of the present invention may support two file forms; a native java class file (. class) is compiled and generated by a compiler of java itself and is applied to a general compiling flow of an existing product. The other one is a virtual class file (.zip. class) generated by the method, and the file only faces the requirement of a source code compiling step and only contains various declaration information in java class.
In a specific compilation scenario improved by the embodiment of the present invention, step 202, it is quickly determined whether the class file is a virtual class by creating a check condition, i.e., checking a suffix of the class file name. If the method loads the virtual class by determining that the ". zip. class" filename suffix is TRUE, i.e., the condition TRUE is TRUE, the process flow goes to step 203; the native java class file name ends with the class suffix, condition FALSE, and program execution branches to step 204.
And step 203, the program performs the reverse flow to acquire various types of declaration information in the original java class through the data writing process of the virtual class file. For example, in this step, a class declaration string is generated by reading line 1, each part of declaration information in the string is split by a comma to form digitalized data, and for the digitalized data, specific declaration content is read according to a subscript during step processing, and for example, subscript 0 is a compiler version number, subscript 1 is a current class Signature (Signature), and subscript 2 is an interface list implemented by a current class. In the above, the interface list is further split as a whole character string by using a space, and each specific interface name is obtained for accurately restoring java-type object data. Other content in the virtual class is obtained in a manner similar to the class declaration information, such as zero or more internal classes, class attributes, and class methods. Taking the internal class as an example, when the virtual class file row 2 is empty when the internal class does not exist, the internal class information is read to judge whether the internal class exists according to the obtained character string length, and when a plurality of internal classes exist, the unit splitting can be carried out through the dividing number.
Through the above operation steps, various statement data of the class file are reassembled into java class objects. These objectified data are stored in the class declaration cache at the time of source code compilation, step 205, for use by the semantic analyzer in subsequent compilation steps.
Step 204, a default java class loader is adopted, the loaded class must be complete and must be a class file generated through java compilation, otherwise, the class loading fails due to the content reading rule of the default logic, and the compiling fails due to semantic analysis of the current source file. In this step, the declaration information and the specific functional implementation content in the java class file are completely read, and as an objectification data of a java class, the class object is loaded to the class declaration cache in the next step, that is, step 205, while in the subsequent semantic analysis step, the specific functional logic content is not read and plays any substantial role except for the declaration information.
And step 205, caching java class object data.
It can be seen from the above processing that, by means of the step 1, the implementation of the step 2 is simple, the influence on the original program compiling process is very small, reading of invalid contents is avoided by loading a simplified virtual class file, and the class loading speed is effectively increased. In addition, the default class loader in the existing compiling step is reserved in the step 2, both 203 and 204 loaders can start working according to the judgment condition 202 in the compiling process without influencing each other, the java class objectified data completed in 205 is loaded, although the contents are slightly different, the declaration structure information is kept consistent, and no difference exists in the subsequent semantic analysis process. In a specific compiling scene, in response to the requirement of loading a large number of source code dependent classes, the loading implementation of the virtual class method can greatly improve the loading speed and obviously save the performance of a computer.
In summary, with the aid of the technical solution of the embodiments of the present invention, the following beneficial effects are achieved:
1. the content of the java files is simplified, the created virtual files can effectively reduce the volume of the source code reference files, the storage space of a disk 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 files in the transmission process is saved.
2. The method provides a set of specific implementation steps for simplifying the content of the java files, and by referring to the steps, developers can conveniently and quickly realize the function in the product.
3. The selective simplification of the content of the source code reference class file is beneficial to improving the loading efficiency of java class objects in the compiling process, and the compiling speed of the source code can be obviously accelerated.
4. For the compiling implementation step in the existing product, by carrying out minimum improvement on the program, the class loader in the compiling step can quickly identify the virtual class, and the influence of the custom loading flow on the original java class loading program is avoided.
5. The virtual class file and class loader with the self-defined content format provide a play space for realizing the compiling requirement of a specific scene
6. The cooperative work of the custom class loader and the default class loader is supported through simple judgment conditions, the processing of java class files in the original compiling step is completely considered, and a perfect solution is provided for the mixed loading of java classes and virtual classes.
System embodiment
According to an embodiment of the present invention, a JAVA language virtual compilation implementation system is provided, fig. 4 is a schematic diagram of the JAVA language virtual compilation implementation system according to the embodiment of the present invention, and as shown in fig. 4, 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 contents into virtual class files; the conversion module 40 is specifically configured to:
loading the java class files into objectified data, and creating corresponding virtual class files;
reading current class declaration information, and writing the current class declaration information into a virtual class file; the main contents of the current class declaration information, which are used for compiling support, include: 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 inner class declaration information includes: an internal class name, an inherited parent class description, its external class description, internal class signature information, and an implemented interface list;
reading the java class attribute, and writing the java class attribute into the virtual class file; the java class attribute comprises: a modifier and a type description, wherein the assignment part determines whether to include according to the requirements of the compilation scenario.
Reading a class method, and writing the class method into a virtual class file, wherein the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and thrown exception type list.
And the loading module 42 is used for loading the java class and the virtual class file. 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, if the loaded native java class file is judged to be the native java class file, the default java class loader is called, and if the loaded native java class file is judged to be the virtual class file, the self-defined virtual class loader is called;
the user-defined virtual class loader is used for performing reverse flow processing to obtain various types of statement information in the original java class according to the data writing process of the virtual class file, reassembling the various types of statement information of the class file into a java class object, and loading the java class object as java class objectified data into a class statement cache for a semantic analysis program in a subsequent compiling step;
and the default java class loader is used for completely reading the statement information and the specific function implementation content in the java class file, and loading the statement information and the specific function implementation content into a class statement cache as the object data of the java class for the use of a 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 with reference to the description of the method embodiment, which is not described herein again.
Apparatus embodiment one
An embodiment of the present invention provides a JAVA language virtual compilation implementation apparatus, as shown in fig. 5, including: a memory 50, a processor 52 and a computer program stored on the memory 50 and executable on the processor 52, which computer program, when executed by the processor 52, carries out the following method steps:
step 301, converting the general java content into a virtual file; step 301 specifically includes:
loading the java class files into objectified data, and creating corresponding virtual class files;
reading current class declaration information, and writing the current class declaration information into a virtual class file; the main contents of the current class declaration information, which are used for compiling support, include: 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 inner class declaration information includes: an internal class name, an inherited parent class description, its external class description, internal class signature information, and an implemented interface list;
reading the java class attribute, and writing the java class attribute into the virtual class file; the java class attribute comprises: a modifier and a type description, wherein the assignment part determines whether to include according to the requirements of the compilation scenario.
Reading a class method, and writing the class method into a virtual class file, wherein the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and thrown exception type list.
Step 302, loading java class and virtual class files.
Step 302 specifically includes the following processing:
step 1, judging whether a loaded native java file or a virtual file is a native java file, if the loaded native java file is judged to be the native java file, executing step 3, and if the loaded native java file is judged to be the virtual file, executing step 2;
step 2, adopting a user-defined virtual class loader, performing flow reverse processing according to the data writing process of the virtual class file to obtain various types of declaration information in the original java class, reassembling the various types of declaration information of the class file into a java class object, and loading the java class object as java class objectified data into a class declaration cache for a semantic analysis program in a subsequent compiling step;
and 3, adopting a default java class loader to completely read the statement information and the specific function realization content in the java class file, and loading the statement information and the specific function realization content as object data of the java class into a class statement cache for a semantic analysis program in a subsequent compiling step.
Device embodiment II
The embodiment of the present invention provides a computer-readable storage medium, on which an implementation program for information transmission is stored, and when being executed by the processor 52, the implementation program implements the following method steps:
step 301, converting the general java content into a virtual file; step 301 specifically includes:
loading the java class files into objectified data, and creating corresponding virtual class files;
reading current class declaration information, and writing the current class declaration information into a virtual class file; the main contents of the current class declaration information, which are used for compiling support, include: 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 inner class declaration information includes: an internal class name, an inherited parent class description, its external class description, internal class signature information, and an implemented interface list;
reading the java class attribute, and writing the java class attribute into the virtual class file; the java class attribute comprises: a modifier and a type description, wherein the assignment part determines whether to include according to the requirements of the compilation scenario.
Reading a class method, and writing the class method into a virtual class file, wherein the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and thrown exception type list.
Step 302, loading java class and virtual class files.
Step 302 specifically includes the following processing:
step 1, judging whether a loaded native java file or a virtual file is a native java file, if the loaded native java file is judged to be the native java file, executing step 3, and if the loaded native java file is judged to be the virtual file, executing step 2;
step 2, adopting a user-defined virtual class loader, performing flow reverse processing according to the data writing process of the virtual class file to obtain various types of declaration information in the original java class, reassembling the various types of declaration information of the class file into a java class object, and loading the java class object as java class objectified data into a class declaration cache for a semantic analysis program in a subsequent compiling step;
and 3, adopting a default java class loader to completely read the statement information and the specific function realization content in the java class file, and loading the statement information and the specific function realization content as object data of the java class into a class statement cache for a semantic analysis program in a subsequent compiling step.
In summary, with the aid of the technical solution of the embodiments of the present invention, the following beneficial effects are achieved:
1. the content of the java files is simplified, the created virtual files can effectively reduce the volume of the source code reference files, the storage space of a disk 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 files in the transmission process is saved.
2. The method provides a set of specific implementation steps for simplifying the content of the java files, and by referring to the steps, developers can conveniently and quickly realize the function in the product.
3. The selective simplification of the content of the source code reference class file is beneficial to improving the loading efficiency of java class objects in the compiling process, and the compiling speed of the source code can be obviously accelerated.
4. For the compiling implementation step in the existing product, by carrying out minimum improvement on the program, the class loader in the compiling step can quickly identify the virtual class, and the influence of the custom loading flow on the original java class loading program is avoided.
5. The virtual class file and class loader with the self-defined content format provide a play space for realizing the compiling requirement of a specific scene
6. The cooperative work of the custom class loader and the default class loader is supported through simple judgment conditions, the processing of java class files in the original compiling step is completely considered, and a perfect solution is provided for the mixed loading of java classes and virtual classes.
The computer-readable storage medium of this embodiment includes, but is not limited to: ROM, RAM, magnetic or optical disks, and the like.
It will be apparent to those skilled in the art that the modules or steps of the present invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. 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 used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A JAVA language virtual compilation implementation method is characterized by comprising the following steps:
converting the general java class content into a virtual class file;
and loading the java class and the virtual class file.
2. The method as claimed in claim 1, wherein converting the general java class content into the virtual class file specifically comprises:
loading the java class files into objectified 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 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;
and reading the class method, and writing the class method into the virtual class file.
3. The method of claim 2,
the main contents of the current class declaration information for compiling support include: 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 inner class declaration information includes: an internal class name, an inherited parent class description, its external class description, internal class signature information, and an implemented interface list;
the java class attribute comprises: a modifier and a type description, wherein the assignment part determines whether to include the modifier according to the requirement of the compiling scene;
the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and thrown exception type list.
4. The method as claimed in claim 1, wherein the loading of java class and virtual class files specifically comprises:
step 1, judging whether a native java class file or the virtual class file is loaded, if the native java class file is judged, executing step 3, and if the native java class file is judged to be the virtual class file, executing step 2;
step 2, adopting a user-defined virtual class loader, performing reverse flow processing according to the data writing process of the virtual class file to obtain various types of declaration information in the original java class, reassembling the various types of declaration information of the class file into a java class object, and loading the java class object as java class objectified data into a class declaration cache for a semantic analysis program in a subsequent compiling step;
and 3, adopting a default java class loader to completely read the statement information and the specific function realization content in the java class file, and loading the statement information and the specific function realization content as object data of the java class into a class statement cache for a semantic analysis program in a subsequent compiling step.
5. A JAVA language virtual compilation implementation system, comprising:
the conversion module is used for converting the general java class contents into virtual class files;
and the loading module is used for loading the java class and the virtual class file.
6. The system of claim 5, wherein the conversion module is specifically configured to:
loading the java class files into objectified 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 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;
and reading the class method, and writing the class method into the virtual class file.
7. The system of claim 6,
the main contents of the current class declaration information for compiling support include: 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 inner class declaration information includes: an internal class name, an inherited parent class description, its external class description, internal class signature information, and an implemented interface list;
the java class attribute comprises: a modifier and a type description, wherein the assignment part determines whether to include the modifier according to the requirement of the compiling scene;
the class method comprises the following steps: method signature, modifier, return value type, method name, parameter type list, and thrown exception type list.
8. The system according to claim 5, wherein the loading module comprises:
the judging submodule is used for judging whether the loaded native java class file or the virtual class file, if the loaded native java class file is judged to be the native java class file, the default java class loader is called, and if the loaded native java class file is judged to be the virtual class file, the self-defined virtual class loader is called;
the user-defined virtual class loader is used for performing reverse flow processing to obtain various types of statement information in the original java class according to the data writing process of the virtual class file, reassembling the various types of statement information of the class file into a java class object, and loading the java class object as java class objectified data into a class statement cache for a semantic analysis program in a subsequent compiling step;
and the default java class loader is used for completely reading the statement information and the specific function implementation content in the java class file, and loading the statement information and the specific function implementation content into a class statement cache as the object data of the java class for the use of a semantic analysis program in the subsequent compiling step.
9. A JAVA language virtual compilation implementation apparatus, comprising: memory, a processor and a computer program stored on the memory and executable on the processor, the computer program when executed by the processor implementing the steps of the JAVA language virtual compilation implementation method of any of claims 1 to 154.
10. A computer-readable storage medium, on which an information transfer implementation program is stored, which, when executed by a processor, implements the steps of the JAVA language virtual compilation implementation method of any one of claims 1 to 4.
CN202010692748.8A 2020-07-17 2020-07-17 Method, system and device for realizing virtual compiling of JAVA language Pending CN111722849A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010692748.8A CN111722849A (en) 2020-07-17 2020-07-17 Method, system and device for realizing virtual compiling of JAVA language

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010692748.8A CN111722849A (en) 2020-07-17 2020-07-17 Method, system and device for realizing virtual compiling of JAVA language

Publications (1)

Publication Number Publication Date
CN111722849A true CN111722849A (en) 2020-09-29

Family

ID=72572808

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010692748.8A Pending CN111722849A (en) 2020-07-17 2020-07-17 Method, system and device for realizing virtual compiling of JAVA language

Country Status (1)

Country Link
CN (1) CN111722849A (en)

Cited By (1)

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

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104503816A (en) * 2014-12-30 2015-04-08 西安电子科技大学 System for automatically converting hardware language VHDL (Vhsic Hardware Description Language) into MSVL (Modeling, Simulation and Verification Language)
US20160259633A1 (en) * 2014-11-18 2016-09-08 Roger James Poon Safely consuming dynamically-typed code from a statically-typed programming language
CN106133684A (en) * 2014-03-27 2016-11-16 微软技术许可有限责任公司 Support the dynamic behaviour in static compilation program
EP3147783A1 (en) * 2015-09-28 2017-03-29 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
CN109992259A (en) * 2019-04-15 2019-07-09 成都四方伟业软件股份有限公司 Function dynamic creation method, apparatus and electronic equipment
CN110162306A (en) * 2018-02-14 2019-08-23 阿里巴巴集团控股有限公司 The just-ahead-of-time compilation method and apparatus of system
CN110825384A (en) * 2019-10-28 2020-02-21 国电南瑞科技股份有限公司 ST language compiling method, system and compiler based on LLVM
KR20200046499A (en) * 2018-10-24 2020-05-07 삼성에스디에스 주식회사 Apparatus and method for compiling partial source code

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106133684A (en) * 2014-03-27 2016-11-16 微软技术许可有限责任公司 Support the dynamic behaviour in static compilation program
US20160259633A1 (en) * 2014-11-18 2016-09-08 Roger James Poon Safely consuming dynamically-typed code from a statically-typed programming language
CN104503816A (en) * 2014-12-30 2015-04-08 西安电子科技大学 System for automatically converting hardware language VHDL (Vhsic Hardware Description Language) into MSVL (Modeling, Simulation and Verification Language)
EP3147783A1 (en) * 2015-09-28 2017-03-29 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
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
CN109992259A (en) * 2019-04-15 2019-07-09 成都四方伟业软件股份有限公司 Function dynamic creation method, apparatus and electronic equipment
CN110825384A (en) * 2019-10-28 2020-02-21 国电南瑞科技股份有限公司 ST language compiling method, system and compiler based on LLVM

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
KONSTANTIN LÄUFER等: "Safe Structural Conformance for Java", 《THE COMPUTER JOURNAL 》, vol. 43, no. 6, 31 January 2000 (2000-01-31), pages 469 *
王贺塞: "基于Hindley-Milner类型系统的函数式语言Leaf的设计实现", 《中国优秀硕士学位论文全文数据库信息科技辑》, no. 3, 15 March 2018 (2018-03-15), pages 138 - 963 *

Cited By (2)

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

Similar Documents

Publication Publication Date Title
EP2340481B1 (en) Caching runtime generated code
US8196129B2 (en) Adaptive class loading
Schwartz et al. Incremental compilation in Magpie
CN112394942B (en) Distributed software development compiling method and software development platform based on cloud computing
EP3198452B1 (en) On-demand loading of dynamic scripting language code for reduced memory usage
CN112612448A (en) Front-end internationalized multi-page packaging method and device and computer equipment
CN110795091B (en) Modularized route decoupling method, storage medium, electronic equipment and system
CN113296786A (en) Data processing method and device, electronic equipment and storage medium
CN115599359A (en) Code generation method, device, equipment and medium
US11036527B2 (en) Class splitting in object-oriented environments
CN115794202A (en) Data configuration method and engine, file system and computer storage medium
CN111722849A (en) Method, system and device for realizing virtual compiling of JAVA language
CN112860412B (en) Service data processing method and device, electronic equipment and storage medium
CN111352631B (en) Interface compatibility detection method and device
CN111435312A (en) Application program management method and device and electronic equipment
CN111124872A (en) Branch detection method and device based on difference code analysis and storage medium
JP2013534347A (en) System and method for execution of high performance computing applications
CN117008920A (en) Engine system, request processing method and device, computer equipment and storage medium
CN107643892B (en) Interface processing method, device, storage medium and processor
CN115599388A (en) API (application programming interface) document generation method, storage medium and electronic equipment
CN112286802B (en) Method and device for testing program performance and electronic equipment
CN114706586A (en) Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium
CN113901025A (en) Database management method, device, equipment and storage medium
CN111273940B (en) Method and device for uploading program file to code warehouse
CN114579135B (en) Installation package generation method and device

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