WO2024114122A1 - 在编译时替换启动页面的方法、电子设备、储存介质 - Google Patents

在编译时替换启动页面的方法、电子设备、储存介质 Download PDF

Info

Publication number
WO2024114122A1
WO2024114122A1 PCT/CN2023/124219 CN2023124219W WO2024114122A1 WO 2024114122 A1 WO2024114122 A1 WO 2024114122A1 CN 2023124219 W CN2023124219 W CN 2023124219W WO 2024114122 A1 WO2024114122 A1 WO 2024114122A1
Authority
WO
WIPO (PCT)
Prior art keywords
page
replaced
module
class information
information
Prior art date
Application number
PCT/CN2023/124219
Other languages
English (en)
French (fr)
Inventor
冯啸
刘明宇
陈宝祥
贾方荣
李梦余
韩培刚
王宏坤
曾程
温亮
席杰
Original Assignee
天津华来科技股份有限公司
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 天津华来科技股份有限公司 filed Critical 天津华来科技股份有限公司
Publication of WO2024114122A1 publication Critical patent/WO2024114122A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Definitions

  • the present disclosure relates to the technical field of computer digital processing based on Android development language, and in particular to a method, electronic device, and storage medium for replacing a startup page during compilation.
  • Android is an open source mobile operating system based on the Linux kernel and other open source software. Android is developed using the Java language. The Android system presents a structure of multiple modules. For example, as shown in Figure 1, page A jumps to page B by writing it into a module through the language. When developing module extensions, if it is found that the logic of page A jumping to page B in the original module does not meet the requirement of jumping to page C, it is necessary to add a jump method to the original module or modify the original jump method, which will cause other codes or designs of the original module to be changed accordingly to adapt to the new jump requirements. Such code is invasive and highly coupled.
  • the present disclosure aims to solve at least one of the technical problems existing in the related art. To this end, the present disclosure provides a method for replacing a startup page during compilation, thereby effectively avoiding the intrusiveness of the code and reducing the coupling.
  • a method for replacing a startup page at compile time comprising: during coding, adding annotations to the class of a page to be replaced in an extension module, wherein the annotations include class information of the page to be replaced and class information of the replaced page; during compilation, inserting intermediate copy information into the replaced page in the original module; during compilation, scanning all locations in the original module that call the class information of the replaced page, and replacing instructions that call the class information of the replaced page with instructions that call the intermediate copy information of the replaced page; during compilation, scanning the annotations in the original module through a compiler, obtaining the class information of the page to be replaced in the annotations, and storing the class information of the page to be replaced; and during compilation,
  • the replacement code is inserted into the location where the App in the original module is started, and the stored class information of the page to be replaced is assigned to the intermediate copy information of the replaced page.
  • the above-mentioned intermediate copy information is used to copy the class information of the replaced page.
  • the above annotations are meta-information attached to the code, which is used for parsing and use during compilation and runtime.
  • the method further includes: inserting the original module through a Java bytecode framework.
  • the above-mentioned method further includes: replacing the above-mentioned original page with the above-mentioned replaced page when the above-mentioned extension module is not referenced; and replacing the above-mentioned original page with the above-mentioned page to be replaced when the above-mentioned extension module is referenced.
  • the startup page replacement method in the encoding process is implemented based on the Android language environment.
  • the present disclosure also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the method described in the present disclosure when executing the computer program.
  • the present disclosure also provides a storage medium having a computer program stored thereon, wherein the computer program implements the method described in the present disclosure when executed by a processor.
  • a computer program product includes computer executable instructions. When the computer executable instructions are executed, they are used to implement the method described in the present disclosure.
  • FIG1 schematically shows a principle diagram of page replacement in the related art according to an embodiment of the present disclosure
  • FIG2 schematically shows a flow chart of a method for replacing a startup page at compile time according to an embodiment of the present disclosure
  • FIG3 schematically shows a method for replacing a startup page at compile time according to an embodiment of the present disclosure.
  • FIG4 schematically shows a block diagram of an apparatus for replacing a startup page at compile time according to an embodiment of the present disclosure
  • FIG5 schematically shows a schematic structural diagram of an electronic device according to an embodiment of the present disclosure
  • connection should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium.
  • connection should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium.
  • a first feature being “above” or “below” a second feature may mean that the first and second features are in direct contact, or that the first and second features are in indirect contact through an intermediate medium.
  • a first feature being “above”, “above” or “above” a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature.
  • a first feature being “below”, “below” or “below” a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
  • FIG. 1 schematically shows a principle diagram of page replacement in the related art according to an embodiment of the present disclosure.
  • the original module 110 includes an original page 111 (for example, called page A) and a replaced page 112 (for example, called page B).
  • the extended module 120 includes a to-be-replaced page 121 (for example, called page C).
  • the processing logic associated with FIG. 1 requires code modification in the original module 110 , resulting in high coupling and intrusive code.
  • the present disclosure provides a method, electronic device, and storage medium for replacing the startup page at compile time, which can be applied to the field of computer digital processing technology based on Android development language.
  • the method for replacing the startup page at compile time includes: during coding, adding annotations to the class of the page to be replaced in the extension module, wherein the annotations include the class information of the page to be replaced and the class information of the replaced page; during compilation, inserting intermediate copy information into the replaced page in the original module; during compilation, scanning all positions of calling the class information of the replaced page in the original module, and replacing the instructions of calling the class information of the replaced page with instructions of calling the intermediate copy information of the replaced page; during compilation, scanning the annotations in the original module through the compiler, obtaining the class information of the page to be replaced in the annotations, and storing the class information of the page to be replaced; during compilation, inserting replacement code at the position where the App is started in the original module, and assigning the stored class information of the page to
  • FIG. 2 schematically shows a flow chart of a method for replacing a startup page during compilation according to an embodiment of the present disclosure.
  • the method 200 for replacing a startup page at compile time includes operations S210 - S250 .
  • an annotation is added to the class of the page to be replaced in the extension module, wherein the annotation includes class information of the page to be replaced and class information of the replaced page.
  • the intermediate copy information is inserted into the replaced page in the original module.
  • the compiler scans the annotations in the original module, obtains the class information of the page to be replaced in the annotation, and stores the class information of the page to be replaced.
  • the replacement code is inserted at the location where the App in the original module is started, and the stored class information of the page to be replaced is assigned to the intermediate copy information of the replaced page.
  • a method for replacing a startup page at compile time is implemented based on an Android language environment.
  • the present invention will first execute the insertion replacement code, and give the class information of the page C to be replaced to the intermediate copy information of the replaced page B.
  • the class information of the replaced page B is replaced with the intermediate copy information during compilation. Therefore, the startup information read by the system is the information of the page C to be replaced, thereby achieving the purpose of replacing the startup page and completing the implicit code call.
  • annotations are meta-information attached to the code, which is used for parsing and use during compilation and runtime.
  • annotations are some meta-information added to the code, which is used for parsing and use during compilation and runtime, and plays the role of description and configuration. Annotations do not affect the actual logic of the code, but only play an auxiliary role.
  • the original module is instrumented through a Java bytecode framework.
  • the Java bytecode framework can include at least one of the following: ASM framework, Javassist framework, Cglib framework, Byte Buddy framework and BCEL framework.
  • ASM framework is a Java class information manipulation framework. It can modify existing classes or dynamically generate classes in binary form. ASM can directly generate binary class files, or dynamically change class behavior before the class is loaded into the Java virtual machine. After reading information from the class file, ASM can change class behavior, analyze class information, and even generate new classes according to user requirements. The original module is plugged in through the ASM framework. Insertion is to add, modify or delete binary code instructions.
  • the intermediate copy information is used to copy the class information of the replaced page.
  • the class information is a binary file containing an execution program, which is composed of a sequence of op code/data pairs and is an intermediate code.
  • FIG3 schematically shows a principle diagram of a method for replacing a startup page during compilation according to an embodiment of the present disclosure.
  • the arrow direction is used to indicate the page jump direction
  • the solid line is used to indicate the explicit call code
  • the dotted line is used to indicate the implicit call code.
  • the original module 310 includes the original page 311 and the replaced page 312.
  • the extended module 320 includes the to-be-replaced page 321.
  • the processing logic of the method 200 for replacing the startup page at compile time provided by the present application is as follows: during coding, an annotation is added to the class of the page to be replaced in the extension module, wherein the annotation includes the class information of the page to be replaced and the class information of the replaced page.
  • the intermediate copy information is inserted into the replaced page 312 in the original module 310.
  • all locations in the original module 310 that call the class information of the replaced page 312 are scanned, and the instructions that call the class information of the replaced page 312 are replaced with instructions that call the intermediate copy information of the replaced page 312.
  • the compiler scans the annotations in the original module 310, obtains the class information of the page to be replaced 321 in the annotations, and stores the class information of the page to be replaced 321.
  • the replacement code is inserted at the location where the App is started in the original module 310, and the stored class information of the page to be replaced 321 is assigned to the intermediate copy information of the replaced page 312.
  • the method 200 for replacing a startup page during compilation may further include the following operations.
  • the original page 311 is replaced with the replaced page 312.
  • the original page 311 is replaced with the to-be-replaced page 321.
  • the coupling is low and the code is not invasive.
  • FIG. 4 schematically shows a block diagram of an apparatus for replacing a startup page during compilation according to an embodiment of the present disclosure.
  • the apparatus 400 for replacing a startup page at compile time may include an adding module 410 , a first inserting module 420 , a first scanning module 430 , a second scanning module 440 , and a second inserting module 450 .
  • the adding module 410 is used to add annotations to the class of the page to be replaced in the extension module during encoding, wherein the annotations include class information of the page to be replaced and class information of the replaced page.
  • the first inserting module 420 is used to insert the intermediate copy information into the replaced page in the original module during compilation.
  • the first scanning module 430 is used to scan all locations in the original module that call the class information of the replaced page during compilation, and replace the instructions that call the class information of the replaced page with instructions that call the intermediate copy information of the replaced page.
  • the second scanning module 440 is used to scan the annotations in the original module through the compiler during compilation, obtain the class information of the page to be replaced in the annotation, and store the class information of the page to be replaced.
  • the second inserting module 450 is used to insert the replacement code at the location where the App is started in the original module during compilation, and assign the stored class information of the page to be replaced to the intermediate copy information of the replaced page.
  • the intermediate copy information is used to copy the class information of the replaced page.
  • annotations are meta-information attached to the code, which is used for parsing and use during compilation and runtime.
  • the apparatus 400 for starting page replacement during encoding may also include an instrumentation module. piece.
  • the instrumentation module is used to instrument the original module through the Java bytecode framework.
  • the original module includes an original page.
  • the apparatus 400 for replacing a startup page during compilation may further include a first replacement module and a second replacement module.
  • the first replacement module is used to replace the original page with the replaced page without referencing the extension module.
  • the second replacement module is used to replace the original page with the page to be replaced when referencing the extension module.
  • a startup page replacement method in a coding process is implemented based on an Android language environment.
  • any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module.
  • any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation.
  • any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them.
  • FPGAs field programmable gate arrays
  • PLAs programmable logic arrays
  • ASICs application specific integrated circuits
  • one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.
  • any multiple of the adding module 410, the first inserting module 420, the first scanning module 430, the second scanning module 440, and the second inserting module 450 can be combined in one module/unit/subunit for implementation, or any one of the modules/units/subunits can be split into multiple modules/units/subunits.
  • at least part of the functions of one or more modules/units/subunits in these modules/units/subunits can be combined with at least part of the functions of other modules/units/subunits and implemented in one module/unit/subunit.
  • At least one of the adding module 410, the first inserting module 420, the first scanning module 430, the second scanning module 440, and the second inserting module 450 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware, and firmware, or by a suitable combination of any of them.
  • FPGA field programmable gate array
  • PLA programmable logic array
  • ASIC application specific integrated circuit
  • the adding module 410, the first inserting module 420, the first scanning module 430, the second scanning module 431, At least one of the module 440 and the second plug-in module 450 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be performed.
  • the device part for replacing the startup page at compile time in the embodiment of the present disclosure corresponds to the method part for replacing the startup page at compile time in the embodiment of the present disclosure.
  • the description of the device part for replacing the startup page at compile time specifically refers to the method part for replacing the startup page at compile time, which will not be repeated here.
  • the present disclosure also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements a method according to an embodiment of the present disclosure when executing the program.
  • the present disclosure also provides a storage medium having a computer program stored thereon, wherein the computer program implements the method according to the embodiment of the present disclosure when executed by a processor.
  • An embodiment of the present disclosure also includes a computer program product, which includes a computer program, which contains program code for executing the method provided by the embodiment of the present disclosure.
  • the program code is used to enable the electronic device to implement the method of replacing the startup page at compile time provided by the embodiment of the present disclosure.
  • the insertion replacement code is executed first, and the class information of the page to be replaced is given to the custom attributes of the replaced page.
  • the class information of the replaced page is replaced with the inserted custom attributes, so the startup information read by the system is the information of the page to be replaced.
  • FIG5 schematically shows a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure.
  • the electronic device may include: a processor 810, a communications interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communications interface 820 and the memory 830 communicate with each other through the communication bus 840.
  • the processor 810 may call the logic instructions in the memory 830 to execute the method of replacing the startup page at compile time.
  • the logic instructions in the memory 830 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
  • the technical solution of the present disclosure, or the part that contributes to the prior art, or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the technical solution of the present disclosure.
  • the aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
  • the present disclosure further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the above-mentioned method for replacing a startup page at compile time.
  • the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
  • each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware.
  • the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM/RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

Landscapes

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

Abstract

本公开提供了一种在编译时替换启动页面的方法、电子设备、储存介质,可以应用于基于Android开发语言的计算机数字处理技术领域。该在编译时替换启动页面的方法包括:在编码期间,对扩展模块中待替换页面的类添加注解,注解包括待替换页面的类信息和被替换页面的类信息;在编译期间,向原模块中被替换页面插入中间复制信息;扫描原模块中所有调用被替换页面的类信息的位置,将调用被替换页面的类信息的指令替换成调用被替换页面的中间复制信息的指令;通过编译器扫描原模块中的注解,获取到注解中的待替换页面的类信息,并存储待替换页面的类信息;在原模块中的App启动的位置插入替换代码,将存储的待替换页面的类信息赋值给被替换页面的中间复制信息。

Description

在编译时替换启动页面的方法、电子设备、储存介质
本申请要求于2022年11月28日提交的、申请号为202211495763.9的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本公开涉及基于Android开发语言的计算机数字处理技术领域,尤其涉及在编译时替换启动页面的方法、电子设备、储存介质。
背景技术
Android是一个基于Linux内核与其他开源软件的开放源代码的移动操作系统,而Android开发用的是Java语言,Android系统呈现的多个模块的结构,例如图1所示,A页面跳转到B页面,是将其通过语言写入一个模块中,而在进行模块扩展开发时,发现原模块中A页面跳转到B页面逻辑不符合跳转到C页面的需求时,需要在原模块增加跳转方法或修改原跳转方法,从而导致原模块其它代码或者设计,要做相应的更改以适应新的跳转要求。这样的代码具有侵入性,耦合性高。
综上所述,如何有效地避免代码的侵入性,降低耦合性,是目前本领域技术人员急需解决的技术问题。
发明内容
本公开旨在至少解决相关技术中存在的技术问题之一。为此,本公开提供一种在编译时替换启动页面的方法,实现有效地避免代码的侵入性,降低耦合性的目的。
根据本公开的一个方面,提供了一种在编译时替换启动页面的方法,包括:在编码期间,对扩展模块中待替换页面的类添加注解,其中,上述注解包括上述待替换页面的类信息和被替换页面的类信息;在编译期间,向原模块中上述被替换页面插入中间复制信息;在编译期间,扫描上述原模块中所有调用上述被替换页面的类信息的位置,将调用上述被替换页面的类信息的指令替换成调用上述被替换页面的上述中间复制信息的指令;在编译期间,通过编译器扫描上述原模块中的上述注解,获取到上述注解中的上述待替换页面的类信息,并存储上述待替换页面的类信息;以及,在编译期间,在上述 原模块中的App启动的位置插入替换代码,将存储的上述待替换页面的类信息赋值给上述被替换页面的上述中间复制信息。
根据本公开的实施例,上述中间复制信息用于复制被替换页面的类信息。
根据本公开的实施例,上述注解为附加在代码中的元信息,用于编译和运行时进行解析和使用。
根据本公开的实施例,上述方法还包括:通过Java字节码框架对上述原模块进行插桩。
根据本公开的实施例,其中,上述原模块包括原始页面,上述方法还包括:在未引用上述扩展模块的情况下,将上述原始页面替换为上述被替换页面;以及,在引用上述扩展模块的情况下,将上述原始页面替换为上述待替换页面。
根据本公开的实施例,其中,上述在编码过程中的启动页面替换方法基于Android语言环境实现。
本公开还提供一种电子设备,包括存储器、处理器及存储在所述存储器上并在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如本公开所述的方法。
本公开还提供一种存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如本公开所述的方法。
根据本公开的另一个方面,提供了一种计算机程序产品,上述计算机程序产品包括计算机可执行指令,上述计算机可执行指令在被执行时用于实现如本公开所述的方法。
本公开的附加方面和优点将在下面的描述中部分给出,部分将从下面的描述中变得明显,或通过本公开的实践了解到。
附图说明
为了更清楚地说明本公开或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本公开的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示意性示出了根据本公开实施例的在相关技术中页面替换的原理图;
图2示意性示出了根据本公开实施例的在编译时替换启动页面的方法的流程图;
图3示意性示出了根据本公开实施例的在编译时替换启动页面的方法本公开的原理 图;
图4示意性示出了根据本公开的实施例的在编译时替换启动页面的装置的框图;
图5示意性示出了根据本公开实施例的电子设备的结构示意图;
附图标记:
810.处理器;820.通信接口;830.存储器(memory);840.通信总线。
具体实施方式
为使本公开的目的、技术方案和优点更加清楚,下面将结合本公开中的附图,对本公开中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本公开一部分实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。以下实施例用于说明本公开,但不能用来限制本公开的范围。
在本公开实施例的描述中,需要说明的是,术语“中心”、“纵向”、“横向”、“上”、“下”、“前”、“后”、“左”、“右”、“竖直”、“水平”、“顶”、“底”、“内”、“外”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本公开实施例和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本公开实施例的限制。此外,术语“第一”、“第二”、“第三”仅用于描述目的,而不能理解为指示或暗示相对重要性。
在本公开实施例的描述中,需要说明的是,除非另有明确的规定和限定,术语“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体连接;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本公开实施例中的具体含义。
在本公开实施例中,除非另有明确的规定和限定,第一特征在第二特征“上”或“下”可以是第一和第二特征直接接触,或第一和第二特征通过中间媒介间接接触。而且,第一特征在第二特征“之上”、“上方”和“上面”可是第一特征在第二特征正上方或斜上方,或仅仅表示第一特征水平高度高于第二特征。第一特征在第二特征“之下”、“下方”和“下面”可以是第一特征在第二特征正下方或斜下方,或仅仅表示第一特征水平高度小于第二特征。
在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示 例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本公开实施例的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。
图1示意性示出了根据本公开实施例的在相关技术中页面替换的原理图。
如图1所示,在100中,箭头方向用于表示页面跳转方向,实线用于表示有显示调用代码。原模块110包括原始页面111(例如,称之为A页面)和被替换页面112(例如,称之为B页面)。扩展模块120包括待替换页面121(例如,称之为C页面)。
与图1相关的处理逻辑需要在原模块110修改代码,导致耦合性高,代码有侵入性。
为了至少部分地解决相关技术中存在的技术问题,本公开提供了一种在编译时替换启动页面的方法、电子设备、储存介质,可以应用于基于Android开发语言的计算机数字处理技术领域。该在编译时替换启动页面的方法包括:在编码期间,对扩展模块中待替换页面的类添加注解,其中,注解包括待替换页面的类信息和被替换页面的类信息;在编译期间,向原模块中被替换页面插入中间复制信息;在编译期间,扫描原模块中所有调用被替换页面的类信息的位置,将调用被替换页面的类信息的指令替换成调用被替换页面的中间复制信息的指令;在编译期间,通过编译器扫描原模块中的注解,获取到注解中的待替换页面的类信息,并存储待替换页面的类信息;在编译期间,在原模块中的App启动的位置插入替换代码,将存储的待替换页面的类信息赋值给被替换页面的中间复制信息。
图2示意性示出了根据本公开实施例的在编译时替换启动页面的方法的流程图。
如图2所示,该在编译时替换启动页面的方法200包括操作S210~S250。
在操作S210,对扩展模块中待替换页面的类添加注解,其中,注解包括待替换页面的类信息和被替换页面的类信息。
在操作S220,向原模块中被替换页面插入中间复制信息。
在操作S230,扫描原模块中所有调用被替换页面的类信息的位置,将调用被替换页面的类信息的指令替换成调用被替换页面的中间复制信息的指令。
在操作S240,通过编译器扫描原模块中的注解,获取到注解中的待替换页面的类信息,并存储待替换页面的类信息。
在操作S250,在原模块中的App启动的位置插入替换代码,将存储的待替换页面的类信息赋值给被替换页面的中间复制信息。
根据本公开的实施例,在编译时替换启动页面的方法基于Android语言环境实现。
本公开当App启动的时候会优先执行到插入替换代码,将待替换页面C页面的类信息给到被替换B页面的中间复制信息,当执行到启动页面被替换B页面的逻辑时,在编译期间将被替换B页面的类信息替换成了中间复制信息,所以系统读取到的启动信息时待替换C页面的信息,达到启动页面替换的目的,完成隐式代码调用。
根据本公开的实施例,注解为附加在代码中的元信息,用于编译和运行时进行解析和使用。
本例中注解是附加在代码中的一些元信息,用于编译和运行时进行解析和使用,起到说明、配置的功能。注解不会影响代码的实际逻辑,仅仅起到辅助性的作用。
根据本公开的实施例,通过Java字节码框架对原模块进行插桩。
Java字节码框架可以包括以下至少之一:ASM框架、Javassist框架、Cglib框架、Byte Buddy框架和BCEL框架。以ASM框架为例,ASM框架是一个Java类信息操控框架。它能够以二进制形式修改已有类或者动态生成类。ASM可以直接产生二进制class文件,也可以在类被加载入Java虚拟机之前动态改变类行为。ASM从类文件中读入信息后,能够改变类行为,分析类信息,甚至能够根据用户要求生成新类。通过ASM框架对原模块进行插桩。插桩是对二进制代码指令进行增加,修改或删除。
根据本公开的实施例,中间复制信息用于复制被替换页面的类信息。
本例中类信息是一种包含执行程序,由一序列op代码/数据对组成的二进制文件,是一种中间码。
下面参考图3,对根据本公开实施例的在编译时替换启动页面的方法200做进一步说明。
图3示意性示出了根据本公开实施例的在编译时替换启动页面的方法的原理图。
如图3所示,在300中,箭头方向用于表示页面跳转方向,实线用于表示有显示调用代码,虚线用于表示隐式调用代码。原模块310包括原始页面311和被替换页面312。扩展模块320包括待替换页面321。
本申请提供的在编译时替换启动页面的方法200的处理逻辑为:在编码期间,对扩展模块中待替换页面的类添加注解,其中,注解包括待替换页面的类信息和被替换页面的类信息。在编译期间,向原模块310中被替换页面312插入中间复制信息。在编译期 间,扫描原模块310中所有调用被替换页面312的类信息的位置,将调用被替换页面312的类信息的指令替换成调用被替换页面312的中间复制信息的指令。在编译期间,通过编译器扫描原模块310中的注解,获取到注解中的待替换页面321的类信息,并存储待替换页面321的类信息。在此基础上,在编译期间,在原模块310中的App启动的位置插入替换代码,将存储的待替换页面321的类信息赋值给被替换页面312的中间复制信息。
根据本公开的实施例,在编译时替换启动页面方法200还可以包括如下操作。
在未引用扩展模块320的情况下,将原始页面311替换为被替换页面312。在引用扩展模块320的情况下,将原始页面311替换为待替换页面321。
根据本公开的实施例,由于本公开提供的在编译时替换启动页面方法200无需修改原模块代码,因而耦合性低,代码没有侵入性。
以上仅是示例性实施例,但不限于此,还可以包括本领域已知的其他在编译时替换启动页面方法,只要能够降低耦合性,避免侵入性即可。
图4示意性示出了根据本公开的实施例的在编译时替换启动页面的装置的框图。
如图4所示,在编译时替换启动页面的装置400可以包括添加模块410、第一插入模块420、第一扫描模块430、第二扫描模块440和第二插入模块450。
添加模块410,用于在编码期间,对扩展模块中待替换页面的类添加注解,其中,注解包括待替换页面的类信息和被替换页面的类信息。
第一插入模块420,用于在编译期间,向原模块中被替换页面插入中间复制信息。
第一扫描模块430,用于在编译期间,扫描原模块中所有调用被替换页面的类信息的位置,将调用被替换页面的类信息的指令替换成调用被替换页面的中间复制信息的指令。
第二扫描模块440,用于在编译期间,通过编译器扫描原模块中的注解,获取到注解中的待替换页面的类信息,并存储待替换页面的类信息。
第二插入模块450,用于在编译期间,在原模块中的App启动的位置插入替换代码,将存储的待替换页面的类信息赋值给被替换页面的中间复制信息。
根据本公开的实施例,中间复制信息用于复制被替换页面的类信息。
根据本公开的实施例,注解为附加在代码中的元信息,用于编译和运行时进行解析和使用。
根据本公开的实施例,在编码过程中的启动页面替换的装置400还可以包括插桩模 块。
插桩模块,用于通过Java字节码框架对原模块进行插桩。
根据本公开的实施例,原模块包括原始页面。
根据本公开的实施例,在编译时替换启动页面的装置400还可以包括第一替换模块和第二替换模块。
第一替换模块,用于在未引用扩展模块的情况下,将原始页面替换为被替换页面。
第二替换模块,用于在引用扩展模块的情况下,将原始页面替换为待替换页面。
根据本公开的实施例,在编码过程中的启动页面替换方法基于Android语言环境实现。
根据本公开的实施例的模块、子模块、单元、子单元中的任意多个、或其中任意多个的至少部分功能可以在一个模块中实现。根据本公开实施例的模块、子模块、单元、子单元中的任意一个或多个可以被拆分成多个模块来实现。根据本公开实施例的模块、子模块、单元、子单元中的任意一个或多个可以至少被部分地实现为硬件电路,例如现场可编程门阵列(FPGA)、可编程逻辑阵列(PLA)、片上系统、基板上的系统、封装上的系统、专用集成电路(ASIC),或可以通过对电路进行集成或封装的任何其他的合理方式的硬件或固件来实现,或以软件、硬件以及固件三种实现方式中任意一种或以其中任意几种的适当组合来实现。或者,根据本公开实施例的模块、子模块、单元、子单元中的一个或多个可以至少被部分地实现为计算机程序模块,当该计算机程序模块被运行时,可以执行相应的功能。
例如,添加模块410、第一插入模块420、第一扫描模块430、第二扫描模块440和第二插入模块450中的任意多个可以合并在一个模块/单元/子单元中实现,或者其中的任意一个模块/单元/子单元可以被拆分成多个模块/单元/子单元。或者,这些模块/单元/子单元中的一个或多个模块/单元/子单元的至少部分功能可以与其他模块/单元/子单元的至少部分功能相结合,并在一个模块/单元/子单元中实现。根据本公开的实施例,添加模块410、第一插入模块420、第一扫描模块430、第二扫描模块440和第二插入模块450中的至少一个可以至少被部分地实现为硬件电路,例如现场可编程门阵列(FPGA)、可编程逻辑阵列(PLA)、片上系统、基板上的系统、封装上的系统、专用集成电路(ASIC),或可以通过对电路进行集成或封装的任何其他的合理方式等硬件或固件来实现,或以软件、硬件以及固件三种实现方式中任意一种或以其中任意几种的适当组合来实现。或者,添加模块410、第一插入模块420、第一扫描模块430、第二扫描 模块440和第二插入模块450中的至少一个可以至少被部分地实现为计算机程序模块,当该计算机程序模块被运行时,可以执行相应的功能。
需要说明的是,本公开的实施例中在编译时替换启动页面的装置部分与本公开的实施例中在编译时替换启动页面的方法部分是相对应的,在编译时替换启动页面的装置部分的描述具体参考在编译时替换启动页面的方法部分,在此不再赘述。
本公开还提供一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现根据本公开实施例的方法。
本公开还提供一种存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现根据本公开实施例的方法。
本公开的实施例还包括一种计算机程序产品,其包括计算机程序,该计算机程序包含用于执行本公开实施例所提供的方法的程序代码,当计算机程序产品在电子设备上运行时,该程序代码用于使电子设备实现本公开实施例所提供的在编译时替换启动页面的方法。
本公开实施例中的上述一个或多个技术方案,至少具有如下技术效果之一:
本公开当App启动时,优先执行到插入替换代码,将待替换页面的类信息给到被替换页面自定义属性,当执行到启动被替换页面的逻辑时,将被替换页面的类信息替换成了插入的自定义属性,所以系统读取到的启动信息时待替换页面的信息。
此种做法对原有代码没有侵入性,并对扩展模块动态支持,不引用不修改,对原有逻辑没有影响。
图5示意性示出了根据本公开实施例的电子设备的结构示意图,如图5所示,该电子设备可以包括:处理器(processor)810、通信接口(Communications Interface)820、存储器(memory)830和通信总线840,其中,处理器810,通信接口820,存储器830通过通信总线840完成相互间的通信。处理器810可以调用存储器830中的逻辑指令,以执行在编译时替换启动页面的方法。
此外,上述的存储器830中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公 开各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
又一方面,本公开还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以执行上述提供的在编译时替换启动页面的方法。
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。
最后应说明的是:以上实施例仅用以说明本公开的技术方案,而非对其限制;尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本公开各实施例技术方案的精神和范围。

Claims (10)

  1. 一种在编译时替换启动页面的方法,包括:
    在编码期间,对扩展模块中待替换页面的类添加注解,其中,所述注解包括所述待替换页面的类信息和被替换页面的类信息;
    在编译期间,向原模块中所述被替换页面插入中间复制信息;
    在编译期间,扫描所述原模块中所有调用所述被替换页面的类信息的位置,将调用所述被替换页面的类信息的指令替换成调用所述被替换页面的所述中间复制信息的指令;
    在编译期间,通过编译器扫描所述原模块中的所述注解,获取到所述注解中的所述待替换页面的类信息,并存储所述待替换页面的类信息;以及
    在编译期间,在所述原模块中的App启动的位置插入替换代码,将存储的所述待替换页面的类信息赋值给所述被替换页面的所述中间复制信息。
  2. 根据权利要求1所述的方法,其中,所述中间复制信息用于复制被替换页面的类信息。
  3. 根据权利要求1所述的方法,其中,所述注解为附加在代码中的元信息,用于编译和运行时进行解析和使用。
  4. 根据权利要求1至3任一项所述的方法,还包括:通过Java字节码框架对所述原模块进行插桩。
  5. 根据权利要求1至3任一项所述的方法,其中,所述原模块包括原始页面,所述方法还包括:
    在未引用所述扩展模块的情况下,将所述原始页面替换为所述被替换页面;以及
    在引用所述扩展模块的情况下,将所述原始页面替换为所述待替换页面。
  6. 根据权利要求1所述的方法,其中,所述在编码过程中的启动页面替换方法基于Android语言环境实现。
  7. 一种在编译时替换启动页面的装置,包括:
    添加模块,用于在编码期间,对扩展模块中待替换页面的类添加注解,其中,所述注解包括所述待替换页面的类信息和被替换页面的类信息;
    第一插入模块,用于在编译期间,向原模块中所述被替换页面插入中间复制信息;
    第一扫描模块,用于在编译期间,扫描所述原模块中所有调用所述被替换页面的 类信息的位置,将调用所述被替换页面的类信息的指令替换成调用所述被替换页面的所述中间复制信息的指令;
    第二扫描模块,用于在编译期间,通过编译器扫描所述原模块中的所述注解,获取到所述注解中的所述待替换页面的类信息,并存储所述待替换页面的类信息;以及
    第二插入模块,用于在编译期间,在所述原模块中的App启动的位置插入替换代码,将存储的所述待替换页面的类信息赋值给所述被替换页面的所述中间复制信息。
  8. 一种电子设备,包括存储器、处理器及存储在所述存储器上并在所述处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现如权利要求1至6任一项所述的方法。
  9. 一种存储介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时实现如权利要求1至6任一项所述的方法。
  10. 一种计算机程序产品,所述计算机程序产品包括计算机可执行指令,所述计算机可执行指令在被执行时用于实现权利要求1至6中任一项所述的方法。
PCT/CN2023/124219 2022-11-28 2023-10-12 在编译时替换启动页面的方法、电子设备、储存介质 WO2024114122A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211495763.9A CN115543342B (zh) 2022-11-28 2022-11-28 在编译时替换启动页面的方法、电子设备、存储介质
CN202211495763.9 2022-11-28

Publications (1)

Publication Number Publication Date
WO2024114122A1 true WO2024114122A1 (zh) 2024-06-06

Family

ID=84721727

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/124219 WO2024114122A1 (zh) 2022-11-28 2023-10-12 在编译时替换启动页面的方法、电子设备、储存介质

Country Status (2)

Country Link
CN (1) CN115543342B (zh)
WO (1) WO2024114122A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115543342B (zh) * 2022-11-28 2023-03-24 天津华来科技股份有限公司 在编译时替换启动页面的方法、电子设备、存储介质

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6895581B1 (en) * 2000-03-30 2005-05-17 Microsoft Corporation Replaceable classes and virtual constructors for object-oriented programming languages
US20130019231A1 (en) * 2011-07-15 2013-01-17 Infineon Technologies Ag Distributed compiling process with instruction signature support
CN108089887A (zh) * 2016-11-18 2018-05-29 阿里巴巴集团控股有限公司 一种新增页面的启动控制方法及装置
CN108897543A (zh) * 2018-06-29 2018-11-27 苏州科达科技股份有限公司 版本的临时编译系统、方法、装置及存储介质
US20190310835A1 (en) * 2017-03-28 2019-10-10 Tencent Technology (Shenzhen) Company Limited Application development method, tool, and device, and storage medium
CN112817657A (zh) * 2021-01-29 2021-05-18 北京奇艺世纪科技有限公司 一种应用程序启动项加载方法、装置、系统及存储介质
CN113391811A (zh) * 2020-03-13 2021-09-14 北京字节跳动网络技术有限公司 函数编译方法、装置、电子设备及计算机可读存储介质
CN114385162A (zh) * 2020-10-16 2022-04-22 腾讯科技(深圳)有限公司 页面编辑方法、装置、设备及存储介质
CN115543342A (zh) * 2022-11-28 2022-12-30 天津华来科技股份有限公司 在编译时替换启动页面的方法、电子设备、存储介质

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6895581B1 (en) * 2000-03-30 2005-05-17 Microsoft Corporation Replaceable classes and virtual constructors for object-oriented programming languages
US20130019231A1 (en) * 2011-07-15 2013-01-17 Infineon Technologies Ag Distributed compiling process with instruction signature support
CN108089887A (zh) * 2016-11-18 2018-05-29 阿里巴巴集团控股有限公司 一种新增页面的启动控制方法及装置
US20190310835A1 (en) * 2017-03-28 2019-10-10 Tencent Technology (Shenzhen) Company Limited Application development method, tool, and device, and storage medium
CN108897543A (zh) * 2018-06-29 2018-11-27 苏州科达科技股份有限公司 版本的临时编译系统、方法、装置及存储介质
CN113391811A (zh) * 2020-03-13 2021-09-14 北京字节跳动网络技术有限公司 函数编译方法、装置、电子设备及计算机可读存储介质
CN114385162A (zh) * 2020-10-16 2022-04-22 腾讯科技(深圳)有限公司 页面编辑方法、装置、设备及存储介质
CN112817657A (zh) * 2021-01-29 2021-05-18 北京奇艺世纪科技有限公司 一种应用程序启动项加载方法、装置、系统及存储介质
CN115543342A (zh) * 2022-11-28 2022-12-30 天津华来科技股份有限公司 在编译时替换启动页面的方法、电子设备、存储介质

Also Published As

Publication number Publication date
CN115543342A (zh) 2022-12-30
CN115543342B (zh) 2023-03-24

Similar Documents

Publication Publication Date Title
WO2024114122A1 (zh) 在编译时替换启动页面的方法、电子设备、储存介质
JP5602597B2 (ja) 外来情報を区分けすることにより仮想マシン・コードをメモリ最適化する方法、コンピュータ・プログラム、およびシステム
US8533695B2 (en) Compile-time bounds checking for user-defined types
US7299462B2 (en) Relocation format for linking
US9038036B2 (en) Generation of source code and executable code from formal descriptions
US20060064576A1 (en) Boot systems and methods
CN111176717B (zh) 生成安装包的方法、装置及电子设备
US20100313184A1 (en) Language-based model for asynchronous operations
CN108595187A (zh) 安卓安装包集成软件开发工具包的法、装置及存储介质
US10268462B2 (en) Emulation device, emulation method, and recording medium storing emulation program
CN111078279B (zh) 字节码文件的处理方法、装置、设备及存储介质
CN112769706B (zh) 组件化路由方法及系统
CN114153521A (zh) 类加载方法和装置
WO2019227899A1 (zh) 程序调用解耦
US6848099B2 (en) Method and system for bidirectional bitwise constant propogation by abstract interpretation
US20180275976A1 (en) Link time optimization in presence of a linker script using path based rules
CN117149209A (zh) 一种代码增量编译方法、装置、计算机设备及存储介质
US10310871B2 (en) Non-transitory computer-readable recording medium storing control program, control device and control method
US20050149270A1 (en) Componentware creating method, apparatus and recording medium
CN112947941A (zh) 一种添加异常处理代码的方法和装置
CN113760291A (zh) 日志输出的方法和装置
CN109460640A (zh) 一种Java程序保护方法、装置、设备及可读存储介质
CN117075958B (zh) 一种适应多机型的固件生成方法、存储介质及电子设备
CN114579135B (zh) 一种安装包生成方法及装置
CN112256324B (zh) 安卓应用程序构建过程中对文件的处理方法及装置