CN106802860A - Useless class detection method and device - Google Patents

Useless class detection method and device Download PDF

Info

Publication number
CN106802860A
CN106802860A CN201510834179.5A CN201510834179A CN106802860A CN 106802860 A CN106802860 A CN 106802860A CN 201510834179 A CN201510834179 A CN 201510834179A CN 106802860 A CN106802860 A CN 106802860A
Authority
CN
China
Prior art keywords
class
useful
useless
file
name
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.)
Granted
Application number
CN201510834179.5A
Other languages
Chinese (zh)
Other versions
CN106802860B (en
Inventor
王蕾
刘文荣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201510834179.5A priority Critical patent/CN106802860B/en
Publication of CN106802860A publication Critical patent/CN106802860A/en
Application granted granted Critical
Publication of CN106802860B publication Critical patent/CN106802860B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a kind of useless class detection method and device, and method therein includes:Create the useless class set and useful class file set of initialization;Class name in the useless class set is iterated matching in the useful class file set of initialization, to remove the class name of the useful class in the useless class set;After the class name of the useful class in the useless class set is removed, by the useless class set cooperation for useless class testing result is exported.The application can realize more efficiently detecting useless class file, for cleaning system redundancy code provides foundation.

Description

Useless class detection method and device
Technical field
The application is related to the communications field, more particularly to a kind of useless class detection method and device.
Background technology
Android is an open source code mobile device operation system based on Linux, due to it It is open and portable therefore widely used by most of electronic product.However, with wireless side Android engineering iteratively fasters, system code amount increases severely, and useless class is also gradually piled up, the exploitation to system Brought inconvenience with maintenance.
The content of the invention
The application proposes a kind of useless class detection method, and the method includes:
Create the useless class set and useful class file set of initialization;
Class name in the useless class set is iterated matching in the useful class file set of initialization, To remove the class name of the useful class in the useless class set;
After the class name of the useful class in the useless class set is removed, it is by the useless class set cooperation Useless class testing result output.
Optionally, the useless class set and useful class file set for creating initialization includes:
Class file in identification target directory;
The class file that will identify that is matched to detect the class file with default useful class sample In useless class and useful class;
The useful class set of the class name creation initialization based on the described useful class for detecting;
Class file based on the described useful class for detecting creates the useful class file set of the initialization;
The useless class set initialized described in class name creation based on the described useless class for detecting.
Optionally, the default useful class sample includes the list of default useful class white list, useful class One or more in directory listing, useful class class name feature list and useful class file feature list;
Before class file in the identification target directory, methods described also includes:
Invalid code in the target directory is removed based on default code cleaning tool.
Optionally, the class name by the useless class set is in the useful class file set of initialization Matching is iterated, is included with the class name for removing the useful class in the useless class set:
Travel through the useless class set;
Class name in the useless class set is carried out with the class file in the useful class file set successively Matching;
Class name in the useless class set is matched in the class file in the useful class file set When, move into the useful class set using the class name as the class name of useful class, and by the class name pair The class file answered moves into the useful class file set as the class file of useful class.
Optionally, methods described also includes:
When moving into the useful class set using the class name as the class name of useful class, and by the class name After corresponding class file moves into the useful class file set as the class file of useful class, have default Marked with class and be set as the first mark;Described first marks and newly add in the useful class set for identifying The class name of useful class;
When the useless class set is not matched in all class files in the useful class file set In class name when, default useful class mark is set as the second mark;Described second marks for identifying The class name of useful class is not added in the useful class set newly.
Optionally, methods described also includes:
Read the default useful class mark;
Judge to read described useful marks whether to be the described first mark;
When the useful class is judged labeled as the described first mark, the useless class set is traveled through again, Class name in the useless class set is matched with the class file in the useful class file set successively, Matching terminates when judging the useful class labeled as the described second mark.
The application also proposes a kind of useless class detection means, and the device includes:
Creation module, useless class set and useful class file set for creating initialization;
Matching module, for by the class name in the useless class set initialization useful class file set In be iterated matching, to remove the class name of the useful class in the useless class set;
Output module, for after the class name of the useful class in the useless class set is removed, by described in Useless class set cooperation is exported for useless class testing result.
Optionally, the creation module specifically for:
Class file in identification target directory;
The class file that will identify that is matched to detect the class file with default useful class sample In useless class and useful class;
The useful class set of the class name creation initialization based on the described useful class for detecting;
Class file based on the described useful class for detecting creates the useful class file set of the initialization;
The useless class set initialized described in class name creation based on the described useless class for detecting.
Optionally, the default useful class sample includes the list of default useful class white list, useful class One or more in directory listing, useful class class name feature list and useful class file feature list;
The creation module is further used for:
Before the class file in recognizing target directory, the mesh is removed based on default code cleaning tool Invalid code in heading record.
Optionally, the matching module specifically for:
Travel through the useless class set;
Class name in the useless class set is carried out with the class file in the useful class file set successively Matching;
Class name in the useless class set is matched in the class file in the useful class file set When, move into the useful class set using the class name as the class name of useful class, and by the class name pair The class file answered moves into the useful class file set as the class file of useful class.
Optionally, the matching module is further used for:
When moving into the useful class set using the class name as the class name of useful class, and by the class name After corresponding class file moves into the useful class file set as the class file of useful class, have default Marked with class and be set as the first mark;Described first marks and newly add in the useful class set for identifying The class name of useful class;
When the useless class set is not matched in all class files in the useful class file set In class name when, default useful class mark is set as the second mark;Described second marks for identifying The class name of useful class is not added in the useful class set newly.
Optionally, the matching module is further used for:
Read the default useful class mark;
Judge to read described useful marks whether to be the described first mark;
When the useful class is judged labeled as the described first mark, the useless class set is traveled through again, Class name in the useless class set is matched with the class file in the useful class file set successively, Matching terminates when judging the useful class labeled as the described second mark.
In the application, by creating the useless class set and useful class file set of initialization, will be described Class name in useless class set is iterated matching in the useful class file set of initialization, to remove The class name of the useful class in useless class set is stated, when the class name of the useful class in the useless class set is moved After removing, by the useless class set cooperation for useless class testing result is exported, due to carrying out nothing in the application During with the detection of class, can take into full account that the reference between the class name of useless class and the class file of useful class is closed System, such that it is able to more efficiently detect useless class file, for cleaning system redundancy code provides foundation.
Brief description of the drawings
Fig. 1 is the flow chart of a kind of useless class detection method that the embodiment of the application one is provided;
Fig. 2 is a kind of flow chart of Iterative matching that the embodiment of the application one is provided;
Fig. 3 is the logic diagram of a kind of useless class detection means that the embodiment of the application one is provided;
Fig. 4 is carrying a kind of client of useless class detection means that the embodiment of the application one is provided Hardware structure diagram.
Specific embodiment
In the related art, when entering line code cleaning, PMD is being normally based on to android wireless sides Or the code cleaning tool such as UCDetector is completed.
However, PMD instruments are typically only capable to useless private method, the privately owned attribute of scanning, and code segment Interior dead code and variable-definition, for other types of its serviceability of code segment None- identified, and PMD instruments do not possess the scan capability of class rank yet.
Although UCDetector instruments can use class white list by being configured with, standard android works are scanned Useless class in journey, but UCDetector is when useless class scanning is carried out, between consideration class Adduction relationship, therefore (can exist in the android engineerings that API is provided for providing the android engineerings of API Quote the class of the API), UCDetector instruments will be unable to accurate definition and go out useful class set, thus cannot Scan all useless class in the project.
It can be seen that, existing code cleaning tool cannot meet the code cleaning demand in real work scene.
In view of this, the application proposes a kind of useless class detection method, by the useless class for creating initialization Set and useful class file set, the class name in the useless class set is literary in the useful class of initialization Matching is iterated in part set, to remove the class name of the useful class in the useless class set, when described After the class name of the useful class in useless class set is removed, by the useless class set cooperation for useless class is detected Result is exported, due to that, when the detection of useless class is carried out, can take into full account the class of useless class in the application Adduction relationship between name and the class file of useful class, it is achieved thereby that can more efficiently detect useless Class file, for cleaning system redundancy code provides foundation.
The application is described below by specific embodiment and with reference to specific application scenarios.
Fig. 1 is refer to, Fig. 1 is a kind of useless class detection method that the embodiment of the application one is provided, application In client, methods described performs following steps:
Step 101, creates the useless class set and useful class file set of initialization;
Step 102, the class name in the useless class set is entered in the useful class file set of initialization Row iteration is matched, to remove the class name of the useful class in the useless class set;
Step 103, after the class name of the useful class in the useless class set is removed, will be described useless Class set cooperation is exported for useless class testing result.
Above-mentioned client can include that the client of the software-oriented developer useless class detection service of offer is soft Part;For example, by taking the exploitation of android engineerings as an example, the client software can be for towards android Developer provides the useless class detection instrument of useless class detection service, and developer can be useless by this Class detection instrument carries out useless class detection to the android engineerings for having created.
Wherein, the hardware environment of above-mentioned client software is carried, is not particularly limited in the present embodiment; For example, it may be PC main frames, mobile terminal or server.
Below with above-mentioned client software to provide useless class detection service towards android developer Illustrated as a example by useless class detection instrument.
In the present embodiment, when developer carries out useless class detection in the android engineerings to having created When, all catalogues under the android engineerings can be carried out recurrence by client software as target directory Scan to recognize all class files of the android engineerings.
Wherein, for android engineerings, because android engineerings use java language as realization Language, therefore the class file of the android engineerings is usually the system file for extending entitled java, client End software, can be to extending entitled java systems when class file is recognized in all catalogues of android engineerings System file is identified.
In addition, client software is before all class files under recognizing the android engineerings, can be with Invalid code in target directory is removed based on default code cleaning tool, such that it is able to avoid useless class It is referred in the invalid code such as the useless member variable of useful class or dead code section.
In the present embodiment, after when all class files of the android engineerings are identified, client is soft All class files that part will can have been identified are matched to detect this with default useful class sample Useful class and useless class in all class files under android engineerings.
Wherein, the default useful class sample can include by the customized useful class white list of developer In list, useful class directory listing, useful class class name feature list and useful class file feature list one Individual or multiple.
For example, when realizing, developer can pre-define out whiteList variables, usedDirList Variable, four kinds of variables of usedNamePrefList variables and usedContentPrefList variables.
Wherein, whiteList variables, as useful class white list list, what expression need not be processed The set of class, the class in the list is useful class.UsedDirList variables, as useful class catalogue row Table, the catalogue under the list is useful class catalogue, and the class in useful class catalogue is useful class. UsedNamePrefList variables, as useful class class name feature list, the list includes some useful The class name characteristic character of class, if the character in the list occurs in class name, such is useful class. UsedContentPrefList variables, as useful class file feature list, list includes some having With the characteristic character of the class file of class, if the character in the list is in class file (i.e. the content of class) Occur, then such is useful class.
Based on this, useful class of the client software in all class files for having identified of detection and useless During class, all class files that can be will identify that are matched respectively more than in four kinds of lists, if With success, then show the class file for useful class, if matching is unsuccessful, show that the class file is useless Class.In this way, client software can detect the useful class in all class files for identifying With useless class.
After useful class and useless class in detecting all class files for identifying, client software can be with The useful class set of the class name creation initialization based on all useful class for detecting;Can be had based on all Class file is read with the file path of class, and the useful class text of initialization is created based on the class file for reading Part set (properties collection of i.e. useful class);The class name wound of all useless class for being also based on detecting Build the useless class set of initialization.
Wherein, the useless class set of the initialization for being completed for establishment, client software can also record this The file path of all useless classes in set, so that in follow-up Iterative matching, the nothing in the set After turning into useful class with class, being easy to be loaded into the class file of the useless class based on this document path above-mentioned is had With in class file set.
In the present embodiment, in due to the useless class set of initialization, may exist by the class of useful class The class name that file is quoted, and class is typically used according to class name in android engineerings, therefore in code In the android engineerings of specification, once the class name in certain useless class set is in useful class file set Class file in can be matched, then class file corresponding with the class name is necessarily used to, now should Class name is cited in the class file in useful class file set, thus class file corresponding with the class name is have Use class.
From this angle, when client software is created that the useful class file set of initialization, useful After class file set and useless class set, can by by the class name in useless class set successively with it is useful Class file in class file set is matched to detect the class name of the useful class in useless class set.
Fig. 2 is referred to, a kind of client softwares of the Fig. 2 shown in the present embodiment is by useless class set Class name is iterated the flow chart of matching in useful class file set.
Client software is starting to be iterated the class name in useless class set in useful class file set Can be default one useful class mark of useful class set before matching.
Wherein, useful class mark can include the first mark and the second mark, and this first is marked for marking Know the class name that useful class is newly added in the useful class set, second mark can be used for mark, and this is useful Do not add the class name of useful class in class set newly.
For example, client software can be default one mark marked as above-mentioned useful class of useful class set Note position, and for the marker bit defines two kinds of mark values of the first mark and the second mark.
Refer to Fig. 2, client software by the class name in useless class set in useful class file set When being iterated matching, the useful class mark can be set to default label first, wherein the acquiescence mark Note can be that the first mark can also be the second mark.
For example, first mark can be the default mark T of useful class set, second mark It is the default flag F of useful class set that can be, client software is set by the useful class mark During for default label, the useful class mark can be set to flag F it can also be provided that mark T (figures The default label shown in 2 is flag F).
Continuing with referring to Fig. 2, after the useful class mark is set to default label by client software, visitor Family end software can travel through useless class set, by the class name in useless class set successively with useful class file collection Class file in conjunction is matched to detect the class name of the useful class in useless class set.
On the one hand, if in matching the useless class set in class file in useful class file set During a certain class name, now the class name is quoted by useful class file, and the corresponding class file of the class name is useful Class, client software can move into useful class set using such as the class name of useful class, while may be used also With the file path based on the pre-recorded class name, using the corresponding class file of the class name as useful class Class file moves into useful class file set.
When such is moved into useful class set by client software, and by such After the corresponding class file of name moves into useful class file set as the class file of useful class, now client is soft Above-mentioned useful class mark can be set to the first mark (shown in Fig. 2 first is labeled as mark T) by part, The class name of useful class is newly added in the useful class set to identify.
Wherein, client software is by above-mentioned useful class mark when the first mark is set to, if client Software is that the default label that the useful class mark is set is the second mark, and now client can be useful by this Class mark is changed to the first mark by the second mark, and then client software can be read in useless class set Next class name is taken to proceed to match with the class file in useful class file set, by that analogy, until Class name in useless class set matches completion.If client software is the silent of the useful class mark setting Recognize labeled as the first mark, now client can not be altered, under directly being read in useless class set One class name proceeds to match with the class file in useful class file set, by that analogy, until useless Class name in class set matches completion.
On the other hand, if not matching the useless class set in class file in useful class file set In a certain class name, now the class name not by useful class class file quote, the corresponding class file of the class name It is useless class, client software can read next class name with useful class file collection in useless class set Class file in conjunction proceeds matching, by that analogy, until the class name in useless class set has been matched Into.
Certainly, if in not matching the useless class set in class file in useful class file set Class name, now the class name in the useless class set is not by the class file reference of useful class, the useless class set The corresponding class file of class name in conjunction is useless class, and in this case, client can have above-mentioned Marked with class and be set to the second mark (shown in Fig. 2 second is labeled as flag F), it is useful to identify this Do not add the class name of useful class in class set newly.
Wherein, client software is by above-mentioned useful class mark when the second mark is set to, if this is useful Class mark is the first mark by client default setting, and now client can be by the useful class mark by the One mark is changed to the second mark, if the useful class mark is the second mark by client default setting, Now client can not be altered, and now epicycle iteration terminates.
Above in association with Fig. 2 describe client software by the class name in useless class set in useful class file When matching is iterated in set one process for taking turns iteration.
In the present embodiment, after a wheel iteration terminates, if with newly adding useful class in class set Class name after, now be may possibly still be present by the class file institute of the useful class of the new addition in useless class set Use the class name for arriving, the i.e. class name cited in the class file of the useful class of the new addition.
Therefore, in this case, if with the class name that useful class is newly added in class set, now Client software can continue start next round iteration, until in useless class set there is no new useful class Class name add when stop.
Continuing with referring to Fig. 2, after a wheel iteration terminates, client software can read above-mentioned useful class Mark, and judge to read described useful mark whether to be described first to mark.
If client software judges the useful class labeled as the first mark, now in useless class set Still the class name of useful class is there may be, client software can carry out next round according to above iterative process Iteration, useful class mark is set to default label, and useless class set is traveled through again, by the nothing Matched with the class file in useful class file set successively with the class name in class set, detailed process is not Repeat again.
It can be seen that, in this way, client software, can constantly by useless class by iteration repeatedly The class name of the useful class in set removes useless class set, and is moved into useful class set.
Continuing with referring to Fig. 2, after client software is by iterating, finally judge what is read When useful mark is for mark, the class name of the useful class in useless class set is all moved into useful class Set, now Iterative matching terminates, and remaining class name is final useless class detection in useless class set As a result.
Now, client software can by current useless class set cooperation be useless class testing result to exploitation Personnel export, and developer can be based on the useless class testing result of client software output, remove and work as Useless class in preceding android engineerings.
It can be seen that, in this way, can take into full account the class name of useless class and useful class class file it Between adduction relationship, such as UCDetector instruments can be avoided due to not considering the adduction relationship between class, And useful class set cannot be gone out without accurate definition, thus being whether there is in android engineerings cannot be scanned With the problem of class.So as to more efficiently detect useless class file.
In addition, what deserves to be explained is, Fig. 2 is shown in flow, and client starts in useless class set When class name is iterated matching in useful class file set, can not also be in another implementation The useful class mark sets default label, but directly performs follow-up matching step, travels through described useless Class set, the class name in useless class set is matched with the class file in useful class file set successively, After a wheel iteration terminates, come to set the first mark or second for the marker bit further according to iteration result Mark, then client software can be by judging that the useful class marks whether to determine to be for the first mark The no iteration for starting next round.
For example, client software still can preset one as above-mentioned useful category for the useful class set The marker bit of note, and for the marker bit defines two kinds of mark values of the first mark and the second mark, and repeatedly Only retain the marker bit during generation matching beginning, client software is not that should specifically be marked labeled as setting Value, but follow-up matching step is directly performed, after a wheel iteration terminates, further according to iteration knot Fruit to set the first mark or the second mark for the marker bit, repeats no more.
In the embodiment above, by creating the useless class set and useful class file set of initialization, Class name in the useless class set is iterated matching in the useful class file set of initialization, with The class name of the useful class in the useless class set is removed, when the class of the useful class in the useless class set Name be removed after, will the useless class set cooperation be useless class testing result output, due in the application When carrying out the detection of useless class, can take into full account between the class name of useless class and the class file of useful class Adduction relationship, is cleaning system redundancy generation it is achieved thereby that useless class file can be detected more efficiently Code provides foundation.
It is corresponding with above method embodiment, present invention also provides the embodiment of device.
Fig. 3 is referred to, the application proposes a kind of useless class detection means 30, is applied to client;Wherein, Refer to Fig. 4, as the hardware structure carried involved by the client of the useless class detection means 30 in, Generally include CPU, internal memory, nonvolatile memory, network interface and internal bus etc.;With software As a example by realization, the useless class detection means 30 is it is generally understood that the computer journey being carried in internal memory Sequence, the logic device that the software and hardware formed after being run by CPU is combined, described device 30 includes:
Creation module 301, useless class set and useful class file set for creating initialization;
Matching module 302, for by the class name in the useless class set initialization useful class file Matching is iterated in set, to remove the class name of the useful class in the useless class set;
Output module 303, for after the class name of the useful class in the useless class set is removed, inciting somebody to action The useless class set cooperation is exported for useless class testing result.
In the present embodiment, the creation module 301 specifically for:
Class file in identification target directory;
The class file that will identify that is matched to detect the class file with default useful class sample In useless class and useful class;
The useful class set of the class name creation initialization based on the described useful class for detecting;
Class file based on the described useful class for detecting creates the useful class file set of the initialization;
The useless class set initialized described in class name creation based on the described useless class for detecting.
In the present embodiment, the default useful class sample include the list of default useful class white list, One in useful class directory listing, useful class class name feature list and useful class file feature list or It is multiple;
The creation module 301 is further used for:
Before the class file in recognizing target directory, the mesh is removed based on default code cleaning tool Invalid code in heading record.
In the present embodiment, the matching module 302 specifically for:
Travel through the useless class set;
Class name in the useless class set is carried out with the class file in the useful class file set successively Matching;
Class name in the useless class set is matched in the class file in the useful class file set When, move into the useful class set using the class name as the class name of useful class, and by the class name pair The class file answered moves into the useful class file set as the class file of useful class.
In the present embodiment, the matching module 302 is further used for:
When moving into the useful class set using the class name as the class name of useful class, and by the class name After corresponding class file moves into the useful class file set as the class file of useful class, have default Marked with class and be set as the first mark;Described first marks and newly add in the useful class set for identifying The class name of useful class;
When the useless class set is not matched in all class files in the useful class file set In class name when, default useful class mark is set as the second mark;Described second marks for identifying The class name of useful class is not added in the useful class set newly.
In the present embodiment, the matching module 302 is further used for:
Read the default useful class mark;
Judge to read described useful marks whether to be the described first mark;
When the useful class is judged labeled as the described first mark, the useless class set is traveled through again, Class name in the useless class set is matched with the class file in the useful class file set successively, Matching terminates when judging the useful class labeled as the described second mark.
Those skilled in the art will readily occur to this after considering specification and putting into practice invention disclosed herein Other embodiments of application.The application is intended to any modification, purposes or the adaptability of the application Change, these modifications, purposes or adaptations follow the general principle of the application and including this Shen Please undocumented common knowledge or conventional techniques in the art.Description and embodiments only by It is considered as exemplary, the true scope of the application and spirit are pointed out by following claim.
It should be appreciated that the application be not limited to be described above and be shown in the drawings it is accurate Structure, and can without departing from the scope carry out various modifications and changes.Scope of the present application is only by institute Attached claim is limited.
The preferred embodiment of the application is the foregoing is only, is not used to limit the application, it is all at this Within the spirit and principle of application, any modification, equivalent substitution and improvements done etc. should be included in Within the scope of the application protection.

Claims (12)

1. a kind of useless class detection method, it is characterised in that the method includes:
Create the useless class set and useful class file set of initialization;
Class name in the useless class set is iterated matching in the useful class file set of initialization, To remove the class name of the useful class in the useless class set;
After the class name of the useful class in the useless class set is removed, it is by the useless class set cooperation Useless class testing result output.
2. method according to claim 1, it is characterised in that the useless class of the establishment initialization Set and useful class file set include:
Class file in identification target directory;
The class file that will identify that is matched to detect the class file with default useful class sample In useless class and useful class;
The useful class set of the class name creation initialization based on the described useful class for detecting;
Class file based on the described useful class for detecting creates the useful class file set of the initialization;
The useless class set initialized described in class name creation based on the described useless class for detecting.
3. method according to claim 2, it is characterised in that the default useful class sample bag Include the list of default useful class white list, useful class directory listing, useful class class name feature list and useful One or more in class file feature list;
Before class file in the identification target directory, methods described also includes:
Invalid code in the target directory is removed based on default code cleaning tool.
4. method according to claim 2, it is characterised in that described by the useless class set Class name initialization useful class file set in be iterated matching, to remove the useless class set In the class name of useful class include:
Travel through the useless class set;
Class name in the useless class set is carried out with the class file in the useful class file set successively Matching;
Class name in the useless class set is matched in the class file in the useful class file set When, move into the useful class set using the class name as the class name of useful class, and by the class name pair The class file answered moves into the useful class file set as the class file of useful class.
5. method according to claim 4, it is characterised in that methods described also includes:
When moving into the useful class set using the class name as the class name of useful class, and by the class name After corresponding class file moves into the useful class file set as the class file of useful class, have default Marked with class and be set as the first mark;Described first marks and newly add in the useful class set for identifying The class name of useful class;
When the useless class set is not matched in all class files in the useful class file set In class name when, default useful class mark is set as the second mark;Described second marks for identifying The class name of useful class is not added in the useful class set newly.
6. method according to claim 5, it is characterised in that methods described also includes:
Read the default useful class mark;
Judge to read described useful marks whether to be the described first mark;
When the useful class is judged labeled as the described first mark, the useless class set is traveled through again, Class name in the useless class set is matched with the class file in the useful class file set successively, Matching terminates when judging the useful class labeled as the described second mark.
7. a kind of useless class detection means, it is characterised in that the device includes:
Creation module, useless class set and useful class file set for creating initialization;
Matching module, for by the class name in the useless class set initialization useful class file set In be iterated matching, to remove the class name of the useful class in the useless class set;
Output module, for after the class name of the useful class in the useless class set is removed, by described in Useless class set cooperation is exported for useless class testing result.
8. device according to claim 7, it is characterised in that the creation module specifically for:
Class file in identification target directory;
The class file that will identify that is matched to detect the class file with default useful class sample In useless class and useful class;
The useful class set of the class name creation initialization based on the described useful class for detecting;
Class file based on the described useful class for detecting creates the useful class file set of the initialization;
The useless class set initialized described in class name creation based on the described useless class for detecting.
9. device according to claim 8, it is characterised in that the default useful class sample bag Include the list of default useful class white list, useful class directory listing, useful class class name feature list and useful One or more in class file feature list;
The creation module is further used for:
Before the class file in recognizing target directory, the mesh is removed based on default code cleaning tool Invalid code in heading record.
10. device according to claim 8, it is characterised in that the matching module specifically for:
Travel through the useless class set;
Class name in the useless class set is carried out with the class file in the useful class file set successively Matching;
Class name in the useless class set is matched in the class file in the useful class file set When, move into the useful class set using the class name as the class name of useful class, and by the class name pair The class file answered moves into the useful class file set as the class file of useful class.
11. devices according to claim 10, it is characterised in that the matching module is further used In:
When moving into the useful class set using the class name as the class name of useful class, and by the class name After corresponding class file moves into the useful class file set as the class file of useful class, have default Marked with class and be set as the first mark;Described first marks and newly add in the useful class set for identifying The class name of useful class;
When the useless class set is not matched in all class files in the useful class file set In class name when, default useful class mark is set as the second mark;Described second marks for identifying The class name of useful class is not added in the useful class set newly.
12. methods according to claim 5, it is characterised in that the matching module is further used In:
Read the default useful class mark;
Judge to read described useful marks whether to be the described first mark;
When the useful class is judged labeled as the described first mark, the useless class set is traveled through again, Class name in the useless class set is matched with the class file in the useful class file set successively, Matching terminates when judging the useful class labeled as the described second mark.
CN201510834179.5A 2015-11-25 2015-11-25 Useless class detection method and device Active CN106802860B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510834179.5A CN106802860B (en) 2015-11-25 2015-11-25 Useless class detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510834179.5A CN106802860B (en) 2015-11-25 2015-11-25 Useless class detection method and device

Publications (2)

Publication Number Publication Date
CN106802860A true CN106802860A (en) 2017-06-06
CN106802860B CN106802860B (en) 2020-09-01

Family

ID=58977416

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510834179.5A Active CN106802860B (en) 2015-11-25 2015-11-25 Useless class detection method and device

Country Status (1)

Country Link
CN (1) CN106802860B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107358099A (en) * 2017-06-09 2017-11-17 南京邮电大学 Useless change quantity measuring method based on LLVM intermediate representation program microtomies
CN110990296A (en) * 2019-12-20 2020-04-10 北京字节跳动网络技术有限公司 Class component identification method, server, terminal and storage medium
CN114090965A (en) * 2021-11-22 2022-02-25 全景智联(武汉)科技有限公司 Java code obfuscation method, system, computer device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0913769A2 (en) * 1997-10-31 1999-05-06 Sun Microsystems, Inc. Method and apparatus for pre-processing and packaging class files
US7543272B1 (en) * 2004-06-25 2009-06-02 Sun Microsystems, Inc. Method and apparatus for finding terminal classes in a collection of programming language classes
CN104268473A (en) * 2014-09-23 2015-01-07 龙芯中科技术有限公司 Method and device for detecting application programs
CN104881496A (en) * 2015-06-15 2015-09-02 北京金山安全软件有限公司 File name identification and file cleaning method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0913769A2 (en) * 1997-10-31 1999-05-06 Sun Microsystems, Inc. Method and apparatus for pre-processing and packaging class files
US7543272B1 (en) * 2004-06-25 2009-06-02 Sun Microsystems, Inc. Method and apparatus for finding terminal classes in a collection of programming language classes
CN104268473A (en) * 2014-09-23 2015-01-07 龙芯中科技术有限公司 Method and device for detecting application programs
CN104881496A (en) * 2015-06-15 2015-09-02 北京金山安全软件有限公司 File name identification and file cleaning method and device

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107358099A (en) * 2017-06-09 2017-11-17 南京邮电大学 Useless change quantity measuring method based on LLVM intermediate representation program microtomies
CN107358099B (en) * 2017-06-09 2020-05-05 南京邮电大学 Useless variable detection method based on LLVM intermediate representation program slicing technology
CN110990296A (en) * 2019-12-20 2020-04-10 北京字节跳动网络技术有限公司 Class component identification method, server, terminal and storage medium
CN110990296B (en) * 2019-12-20 2023-10-13 抖音视界有限公司 Identification method of class component, server, terminal and storage medium
CN114090965A (en) * 2021-11-22 2022-02-25 全景智联(武汉)科技有限公司 Java code obfuscation method, system, computer device and storage medium
CN114090965B (en) * 2021-11-22 2024-05-17 全景智联(武汉)科技有限公司 Java code confusion method, system, computer equipment and storage medium

Also Published As

Publication number Publication date
CN106802860B (en) 2020-09-01

Similar Documents

Publication Publication Date Title
US10705748B2 (en) Method and device for file name identification and file cleaning
CN107346336B (en) Information processing method and device based on artificial intelligence
US20180218077A1 (en) Method and apparatus for searching application and mobile terminal
WO2022111548A1 (en) Contract review method and apparatus, and readable storage medium
CN111292752B (en) User intention recognition method and device, electronic equipment and storage medium
US20200210053A1 (en) Systems, devices and methods for electronic determination and communication of location information
US20170357486A1 (en) Enhancing a crowdsourced integrated development environment application
CN110705235B (en) Information input method and device for business handling, storage medium and electronic equipment
US10726357B2 (en) Cross-platform program analysis using machines learning based on universal features
US20190005057A1 (en) Methods and Devices for File Folder Path Identification and File Folder Cleaning
CN106802860A (en) Useless class detection method and device
CN106528835A (en) Information acquisition method and device
US8296785B2 (en) Providing links between application programs
US20150278231A1 (en) System and method for customizing archive of a device driver generator tool for a user
CN104423623A (en) To-be-selected word processing method and electronic equipment
CN112966824A (en) Deployment method and device of inference library and electronic equipment
CN111124421B (en) Abnormal contract data detection method and device for blockchain intelligent contract
CN113961768A (en) Sensitive word detection method and device, computer equipment and storage medium
US20170371652A1 (en) Automated generation and identification of screenshots for translation reference
CN109558600A (en) Translation processing method and device
CN105681175A (en) Method and device of modifying contact person head portrait in instant messaging application
CN107656627B (en) Information input method and device
US9495147B2 (en) Method and apparatus for obtaining context information for a software development task
CN111339776B (en) Resume parsing method and device, electronic equipment and computer-readable storage medium
CN113849415A (en) Control testing method and device, storage medium and electronic equipment

Legal Events

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

Effective date of registration: 20200918

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200918

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: Alibaba Group Holding Ltd.