A kind of method and apparatus calling relating module
Technical field
The application belongs to intelligent television field, particularly relates to a kind of method and apparatus calling relating module.
Background technology
TV is modal household electrical appliance in modern society, along with the development of science and technology, has standard-sized sheet
Putting formula platform, the intelligent television being equipped with operating system also arises at the historic moment.User is based on this intelligent television
While appreciating general television content, types of applications software can be installed and uninstalled voluntarily, sustainable to intelligence
The function of energy TV carries out expanding and upgrading, it is possible to bring abundant individualized experience to user.
Intelligent television uses Android (android) system at present.Framework at Android system is developed
During, specially in the development process of ccf layer, the side operator added in the jar bag of java has higher limit
65536, and the framework.jar under android wraps in and adds substantial amounts of method in compilation process, causes
Side operator in framework.jar bag exceedes higher limit, reports an error so that this jar bag cannot generate.
In prior art, the method solving to add in jar bag exceeds the method for higher limit for selecting in jar bag
Part of module set up new jar bag removal, selection according to be this removal module be with jar bag in other
The uncorrelated module of module, but module uncorrelated with other modules is less, even if the module that will select
After setting up the removal of new jar bag, the side operator that can continue in this former jar bag add is little so that this removal
Have little significance.
Framework.jar bag also has other have the module of relatively multi-method, remove this module, can make former
Jar bag increases substantial amounts of side operator.But, owing to having, the module of relatively multi-method is general and other modules
Having association, this module with relatively multi-method is called relating module, is once removed by this relating module,
Can make to call this relating module when the compiling of framework.jar bag generates and mistake occurs, it is impossible to generate
Framework.jar bag, it is impossible to realize correct compilation process, causes the final Android system cannot be just
Really compiling.
Summary of the invention
In view of this, the purpose of the application is to provide a kind of method and apparatus calling relating module, adopts
Use java reflex mechanism, reverse calling relating module so that compilation process is independent of relating module, move
Normal call relating module is not affected, it is ensured that the function of framework.jar bag after going out.
A kind of method calling relating module, described relating module is to move in framework.jar bag in advance
The relating module with default bag name gone out, the method includes:
According to the default bag name of described relating module, obtain the bag of described relating module, and in described pass
Searching target class in the bag of gang mould block, described target class is unappropriated class;
When finding target class, searching goal approach in described target class, described goal approach is not
Occupied method;
When finding goal approach in described target class, obtain described goal approach and described target side
The method parameter of method;
Utilize java reflex mechanism, described goal approach and method parameter are reflected and calls to framework.jar
Bag, so that the compiling of described framework.jar bag is correctly carried out.
Above-mentioned method, it is preferred that described after finding target class, searches in described target class
Before goal approach, also include:
Carry out assignment for described target class to take.
Above-mentioned method, it is preferred that after finding goal approach in described target class, obtains institute
Before stating the method parameter of goal approach and described goal approach, also include:
Take for described goal approach assignment.
Above-mentioned method, it is preferred that remove relating module in advance in framework.jar bag and include:
When judging to obtain that in framework.jar bag, side operator reaches default higher limit, by described association
Module removes;
The described relating module that java reflex mechanism is removal is utilized to preset bag name, and by described relating module
Default bag name feed back to framework.jar bag;
The default bag name of described relating module is sent in the Android.mk to Java.jar bag so that
Described Android.mk increases the default bag name of described relating module.
Above-mentioned method, it is preferred that also include:
When the bag at described relating module is not searched target class or when not searching in described target class
During to goal approach, generate warning message and report to the police.
A kind of device calling relating module, described relating module is to move from framework.jar bag in advance
The relating module with default bag name gone out, this device includes:
First searches unit, for the default bag name according to described relating module, obtains described pass gang mould
The bag of block, and in the bag of described relating module, search target class, described target class is unappropriated class;
Second searches unit, for when finding target class, searches goal approach in described target class,
Described goal approach is unappropriated method;
Acquiring unit, in time finding goal approach in described target class, obtains described goal approach
And the method parameter of described goal approach;
Reflector element, is used for utilizing java reflex mechanism, described goal approach and method parameter is reflected and adjusts
With to framework.jar bag, so that the compiling of described framework.jar bag is correctly carried out.
Above-mentioned device, it is preferred that also include:
Class takies unit, for after finding target class, searches goal approach in described target class
Before, carry out assignment for described target class to take.
Above-mentioned device, it is preferred that also include:
Method takies unit, for after finding goal approach in described target class, obtains described
Before the method parameter of goal approach and described goal approach, take for described goal approach assignment.
Above-mentioned device, it is preferred that also include:
Removal unit, for when judging that obtaining side operator in framework.jar bag reaches default higher limit
Time, described relating module is removed;
Preset bag name unit, for utilizing the described relating module that java reflex mechanism is removal to preset bag name;
Transmitting element, for the default bag name of described relating module is fed back to framework.jar bag, and
And the default bag name of described relating module is sent in the Android.mk to Java.jar bag so that institute
State Android.mk and increase the default bag name of described relating module.
Above-mentioned device, it is preferred that also include:
Alarm unit, for when not searching target class or when described in the bag at described relating module
When target class does not finds goal approach, generate warning message and report to the police.
This application provides a kind of method calling relating module, described relating module be in advance from
The relating module with default bag name of removal in framework.jar bag, the method includes: according to described
The default bag name of relating module, obtain the bag of described relating module, and in the bag of described relating module
Searching target class, described target class is unappropriated class;When finding target class, in described target
Apoplexy due to endogenous wind searches goal approach, and described goal approach is unappropriated method;Described target class is searched
During to goal approach, obtain described goal approach and the method parameter of described goal approach;Utilize java
Reflex mechanism, reflects described goal approach and method parameter and calls.Use java reflex mechanism, reversely
Call the method in the relating module having been moved out framework.jar bag so that compilation process is independent of close
Gang mould block, does not affect normal call relating module, it is ensured that the function of framework.jar bag after removal.
Accompanying drawing explanation
In order to be illustrated more clearly that the embodiment of the present application or technical scheme of the prior art, below will be to reality
Execute the required accompanying drawing used in example or description of the prior art to be briefly described, it should be apparent that below,
Accompanying drawing in description is some embodiments of the application, for those of ordinary skill in the art, not
On the premise of paying creative work, it is also possible to obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is the flow chart of a kind of embodiment of the method 1 calling relating module that the application provides;
Fig. 2 is another flow chart of a kind of embodiment of the method 1 calling relating module that the application provides;
Fig. 3 is the flow chart of a kind of embodiment of the method 2 calling relating module that the application provides;
Fig. 4 is the flow chart of a kind of embodiment of the method 3 calling relating module that the application provides;
Fig. 5 is the structural representation of a kind of device embodiment 1 calling relating module that the application provides;
Fig. 6 is that the another kind of structure of a kind of device embodiment 1 calling relating module that the application provides is shown
It is intended to;
Fig. 7 is the structural representation of a kind of device embodiment 2 calling relating module that the application provides;
Fig. 8 is the structural representation of a kind of device embodiment 3 calling relating module that the application provides.
Detailed description of the invention
For making the purpose of the embodiment of the present application, technical scheme and advantage clearer, below in conjunction with this Shen
Please accompanying drawing in embodiment, the technical scheme in the embodiment of the present application is clearly and completely described,
Obviously, described embodiment is some embodiments of the present application rather than whole embodiments.Based on
Embodiment in the application, those of ordinary skill in the art are obtained under not making creative work premise
The every other embodiment obtained, broadly falls into the scope of the application protection.
In the embodiment of the present application, can be that framework.jar bag is any be associated relating module with other modules
Module, be typically the module of relatively multi-method, such as, webkit module, bluetooth module, phone
The various module such as module.
Embodiment 1
See Fig. 1, it is shown that a kind of method flow diagram calling relating module that the embodiment of the present application 1 provides,
Including:
Step S101: according to the default bag name of described relating module, obtain the bag of described relating module,
And in the bag of described relating module, search target class;
In the present embodiment relating module be in advance from framework.jar bag removal there is default bag name
Relating module, is to have related module with other modules in framework.jar bag.
Wherein, described target class is unappropriated class.
In invoked procedure, it is first depending on the default bag name of relating module, obtains the bag of this relating module,
When the bag of this relating module is to be removed by this relating module, this relating module is moved as a new jar bag
Going out, the bag of this relating module is preset with bag name, and then searches target class in the bag of relating module, in order to
Prevent because the same class in relating module is repeatedly called and makes compilation process go wrong, therefore,
Needing the unappropriated class calling in relating module, i.e. this target class is unappropriated class.
Step S102: when finding target class, searches goal approach in described target class;
Wherein, described goal approach is unappropriated method.
After finding target class in the bag of relating module, in this target class, continue to search for goal approach,
Similar with target class, make because the same method in target class is repeatedly called to prevent
Compilation process goes wrong, accordingly, it would be desirable to the unappropriated method of invocation target apoplexy due to endogenous wind, i.e. the method
For unappropriated method.
Step S103: when finding goal approach in described target class, obtains described goal approach and institute
State the method parameter of goal approach;
When finding goal approach in target class, during obtaining this goal approach, obtain simultaneously
The method parameter of this goal approach, in order to when calling the method, obtains the content that the method is whole: side
Method and method parameter.
Step S104: utilize java reflex mechanism, described goal approach and method parameter are reflected call to
Framework.jar bag, so that the compiling of described framework.jar bag is correctly carried out.
Utilize java reflex mechanism, this goal approach and method parameter are reflected and calls to framework.jar
Bag so that this framework.jar bag is compiled according to this goal approach and method parameter.
Utilize java reflex mechanism to substitute former call method, the method in relating module is called, real
Show the method calling in relating module, reached same effect of calling, and compile and be independent of this pass gang mould
The source code of block, is not affected by removing this relating module, it is ensured that make described framework.jar bag
Compiling is correctly carried out.
See Fig. 2, it is shown that another of a kind of method calling relating module that the embodiment of the present application 1 provides
Flow chart, in the flow chart shown in Fig. 1, also includes step S105 between step S101 and step S102,
Step S106 is also included between step S102 and step S103;
Step S105: when finding target class, carries out assignment for described target class and takies.
In invoked procedure, the bag of relating module is searched target class, in order to prevent because of relating module
In same class repeatedly called and compilation process gone wrong, accordingly, it would be desirable to call pass gang mould
Unappropriated class in block, i.e. this target class are unappropriated class.
During in order to prevent from calling next time, this target class is called again, and therefore, is finding this target
After class, carry out assignment for this target class and take, next time in invoked procedure, from remaining unappropriated
Apoplexy due to endogenous wind selects target class.
Step S106: when finding goal approach in described target class, for described goal approach assignment
Take.
When finding goal approach in target class, during obtaining this goal approach, obtain simultaneously
The method parameter of this goal approach, in order to when calling the method, obtains the content that the method is whole: side
Method and method parameter.
During in order to prevent from calling next time, this goal approach is called again, and therefore, is finding this mesh
After mark method, this goal approach is carried out assignment and takies, next time in invoked procedure, from remaining not by
The method taken selects goal approach.
To sum up, a kind of method calling relating module that the embodiment of the present application 1 provides, use java reflection
Mechanism, reverse calling has been moved out the method in the relating module of framework.jar bag, reaches same tune
By effect so that compilation process is independent of relating module, after removal, do not affect normal call relating module,
Ensure the function of framework.jar bag.
Embodiment 2
See Fig. 3, it is shown that a kind of method flow diagram calling relating module that the embodiment of the present application 2 provides,
Before flow chart step S101 shown in Fig. 1, also include:
Step S107: when judging to obtain that in framework.jar bag, side operator reaches default higher limit,
Described relating module is removed;
This higher limit can be the higher limit 65536 of jar bag, it is also possible to for default one less than this 65536
Integer value so that perform removal course of action in, remain able to continue at framework.jar bag
Middle adding method.
When adding that in framework.jar bag, side operator reaches default higher limit to, for ensureing that compiling should
Can correctly carry out during framework.jar bag, then need to be removed by this relating module, in this relating module
There is more side operator, remove this relating module, it is possible to add more side for framework.jar bag
Method provides space.
Step S108: utilize the described relating module that java reflex mechanism is removal to preset bag name, and by institute
The default bag name stating relating module feeds back to framework.jar bag;
This relating module utilizing java reflex mechanism to be removal presets a bag name, and this is preset
Bag name is sent to framework.jar bag, so that calling this relating module by framework.jar bag
In method time, just can be found the relating module of this removal by this default bag name.
Step S109: the default bag name of described relating module is sent the Android.mk to Java.jar bag
In so that described Android.mk increases the default bag name of described relating module.
The compilation process of Java.jar is system layer compiling, in order to ensure that the compiling of system layer should not by removal
The impact of relating module, needs to send to Java.jar bag the default bag name of this removal module
In Android.mk, in order to when system layer calls the goal approach in this relating module, it is possible to do not move out
Before this relating module to call result identical so that the compiling of described Java.jar bag is correctly carried out.
To sum up, the embodiment of the present application 2 provides a kind of method calling relating module, also includes in advance
The process of relating module is removed, in this process, by the relating module of removal from framework.jar bag
Default bag name be sent in the Android.mk in framework.jar bag and Java.jar bag, it is ensured that
The method called in the compilation process made with do not move out this relating module before to call result identical.
Embodiment 3
See Fig. 4, it is shown that the flow process of a kind of method calling relating module that the embodiment of the present application 3 provides
Figure, in the flow chart shown in Fig. 1, also includes:
Step S110: judge whether to find target class from the bag of described relating module, if found,
Perform step S102, otherwise perform step S112;
When not finding target class in the bag of relating module, then explanation is broken down, and generates alarm signal
Breath is reported to the police, and programming by prompting personnel break down, and the bag Program of relating module is checked, adjusted.
Step S111: judging whether to find goal approach from described target class, if found, holding
Row step S103, otherwise performs step S112;
Step S112: generate warning message and report to the police.
When not finding goal approach in target class, then explanation is broken down, and generates warning message report
Alert, programming by prompting personnel break down, and the program of target class is checked, adjusted.
The mode that warning message is reported to the police can be multiple, such as: generates pop-up and carries out pointing out, generating warning
The various modes such as sound prompting, concrete mode can be configured according to practical situation, the most superfluous in the present embodiment
State.
To sum up, the embodiment of the present application 3 provides a kind of method calling relating module, also includes: when
When not searching target class in the bag of described relating module or when not finding target in described target class
During method, generate warning message and report to the police.When breaking down, it is ensured that programming personnel can obtain information,
And then the program that this fault occurs checks, adjusts.
A kind of embodiment of the method calling relating module provided with above-mentioned the application is corresponding, the application
Description additionally provides a kind of device embodiment calling relating module.
Embodiment 1
See Fig. 5, it is shown that the structure of a kind of device embodiment 1 calling relating module that the application provides
Schematic diagram, including: first searches unit 101, second searches unit 102, acquiring unit 103 and reflection
Unit 104;
Wherein, described first searches unit 101, for the default bag name according to described relating module,
To the bag of described relating module, and in the bag of described relating module, search target class;
In the present embodiment relating module be in advance from framework.jar bag removal there is default bag name
Relating module, is to have related module with other modules in framework.jar bag.
Wherein, described target class is unappropriated class.
In invoked procedure, first searches unit 101 is first depending on the default bag name of relating module, obtains
The bag of this relating module, when the bag of this relating module is to be removed by this relating module, makees this relating module
Being a new jar bag removal, the bag of this relating module is preset with bag name, and then in the bag of relating module
Search target class, be made compiled in order to prevent because the same class in relating module is repeatedly called
Journey goes wrong, accordingly, it would be desirable to the unappropriated class called in relating module, i.e. this target class are not
Occupied class.
Wherein, described second searches unit 102, for when finding target class, in described target class
Search goal approach;
Wherein, described goal approach is unappropriated method.
After the first lookup unit 101 finds target class in the bag of relating module, second searches unit
102 continue to search for goal approach in this target class, similar with target class, in order to prevent because of target
The same method of apoplexy due to endogenous wind is repeatedly called and compilation process is gone wrong, accordingly, it would be desirable to call mesh
The unappropriated method of mark apoplexy due to endogenous wind, i.e. the method is unappropriated method.
Wherein, described acquiring unit 103, in time finding goal approach in described target class, obtain
Described goal approach and the method parameter of described goal approach;
When the second lookup unit 102 finds goal approach in target class, acquiring unit 103 obtains
During this goal approach, obtain the method parameter of this goal approach, in order to calling the method simultaneously
Time, obtain the content that the method is whole: method and method parameter.
Wherein, described reflector element 104, it is used for utilizing java reflex mechanism, by described method and method
Parametric reflective calls to framework.jar bag, so that the compiling of described framework.jar bag is correctly entered
OK.
Reflector element 104 utilizes java reflex mechanism, this goal approach and method parameter are reflected call to
Framework.jar bag so that this framework.jar bag is compiled according to this goal approach and method parameter
Translate.
Utilize java reflex mechanism to substitute former call method, the method in relating module is called, real
Show the method calling in relating module, reached same effect of calling, and compile and be independent of this pass gang mould
The source code of block, is not affected by removing this relating module, it is ensured that make described framework.jar bag
Compiling is correctly carried out.
See Fig. 6, it is shown that another of a kind of device embodiment 1 calling relating module that the application provides
Plant structural representation, in the structure shown in Fig. 5, also include: class takies unit 105 and method takies list
Unit 106;
Wherein, described class takies unit 105, for after finding target class, in described target class
Before searching goal approach, carry out assignment for described target class and take.
In invoked procedure, the bag of relating module is searched target class, in order to prevent because of relating module
In same class repeatedly called and compilation process gone wrong, accordingly, it would be desirable to call pass gang mould
Unappropriated class in block, i.e. this target class are unappropriated class.
During in order to prevent from calling next time, this target class is called again, and therefore, searches unit first
After 101 find this target class, class takies unit 105 and carries out assignment for this target class and take, and adjusts next time
During with, select target class from remaining unappropriated apoplexy due to endogenous wind.
Wherein, described method takies unit 106, for when find in described target class goal approach it
After, before obtaining the method parameter of described goal approach and described goal approach, for described goal approach
Assignment takies.
When finding goal approach in target class, during obtaining this goal approach, obtain simultaneously
The method parameter of this goal approach, in order to when calling the method, obtains the content that the method is whole: side
Method and method parameter.
During in order to prevent from calling next time, this goal approach is called again, and therefore, searches single second
After unit 102 finds this goal approach, method takies unit 106 and this goal approach is carried out assignment takies,
Next time in invoked procedure, from remaining unappropriated method, select goal approach.
To sum up, a kind of device calling relating module that the embodiment of the present application 1 provides, use java reflection
Mechanism, reverse calling has been moved out the method in the relating module of framework.jar bag, reaches same tune
By effect so that compilation process is independent of relating module, after removal, do not affect normal call relating module,
Ensure the function of framework.jar bag.
Embodiment 2
See Fig. 7, it is shown that the structure of a kind of device embodiment 2 calling relating module that the application provides
Schematic diagram, in the structure shown in Fig. 5, also includes: removes unit 107, presets bag name unit 108 and send out
Send unit 109;
Wherein, described removal unit 107, reach for side operator in judgement obtains framework.jar bag
During to the higher limit preset, described relating module is removed;
This higher limit can be the higher limit 65536 of jar bag, it is also possible to for default one less than this 65536
Integer value so that perform removal course of action in, remain able to continue at framework.jar bag
Middle adding method.
When adding that in framework.jar bag, side operator reaches default higher limit to, for ensureing that compiling should
Can correctly carry out during framework.jar bag, then need to be removed by this relating module, in this relating module
Having more side operator, removal unit 107 removes this relating module, it is possible to for framework.jar bag
Add more method and space is provided.
Wherein, described default bag name unit 108, for utilizing java reflex mechanism for the described pass of removal
Gang mould block presets bag name;
Presetting bag name unit 108 utilizes this relating module that java reflex mechanism is removal to preset a bag name.
Wherein, described transmitting element 109, for feeding back to the default bag name of described relating module
Framework.jar bag, and the default bag name of described relating module is sent to Java.jar bag
In Android.mk so that described Android.mk increases the default bag name of described relating module.
This bag name preset is sent to framework.jar bag, so that passing through by transmitting element 109
When framework.jar bag calls the method in this relating module, just can find this by this default bag name
The relating module of removal
The compilation process of Java.jar is system layer compiling, in order to ensure that the compiling of system layer should not by removal
The impact of relating module, it is also desirable to the default bag name of this removal module is sent extremely by transmitting element 109
In the Android.mk of Java.jar bag, in order to when system layer calls the goal approach in this relating module, energy
Enough with do not move out this relating module before to call result identical so that the compiling of described Java.jar bag is correct
Carry out.
To sum up, the embodiment of the present application 2 provides a kind of device calling relating module, also includes in advance
From framework.jar bag, remove the removal unit of relating module, preset bag name unit and transmitting element,
The default bag name of the relating module of removal is sent in framework.jar bag and Java.jar bag
In Android.mk, it is ensured that the method called in the compilation process made with do not move out this relating module before
To call result identical.
Embodiment 3
See Fig. 8, it is shown that the structure of a kind of device embodiment 3 calling relating module that the application provides
Schematic diagram, in the structure shown in Fig. 5, also includes: alarm unit 110;
Alarm unit, for when not searching target class or when described in the bag at described relating module
When target class does not finds goal approach, generate warning message and report to the police.
When not finding target class in the bag of relating module, then explanation is broken down, alarm unit 110
Generation warning message is reported to the police, and programming by prompting personnel break down, and examines the bag Program of relating module
Look into, adjust.
In like manner, when not finding goal approach in target class, then explanation is broken down, alarm unit
110 generate warning messages reports to the police, and programming by prompting personnel break down, the program of target class is checked,
Adjust.
The mode that warning message is reported to the police can be multiple, such as: generates pop-up and carries out pointing out, generating warning
The various modes such as sound prompting, concrete mode can be configured according to practical situation, the most superfluous in the present embodiment
State.
To sum up, the embodiment of the present application 3 provides a kind of device calling relating module, also includes: when
When not searching target class in the bag of described relating module or when not finding target in described target class
During method, generate the alarm unit that warning message is reported to the police.When breaking down, it is ensured that programming personnel can
Obtain information, and then the program that this fault occurs checks, adjusts.
Above to a kind of method and apparatus calling relating module provided by the present invention, carry out detailed Jie
Continuing, principle and the embodiment of the present invention are set forth by specific case used herein, above reality
The explanation executing example is only intended to help to understand method and the core concept thereof of the present invention;Simultaneously for ability
The those skilled in the art in territory, according to the thought of the present invention, the most all can
Change part.In sum, this specification content should not be construed as limitation of the present invention.