CN106802860B - Useless class detection method and device - Google Patents

Useless class detection method and device Download PDF

Info

Publication number
CN106802860B
CN106802860B CN201510834179.5A CN201510834179A CN106802860B CN 106802860 B CN106802860 B CN 106802860B CN 201510834179 A CN201510834179 A CN 201510834179A CN 106802860 B CN106802860 B CN 106802860B
Authority
CN
China
Prior art keywords
class
useful
useless
mark
useful class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510834179.5A
Other languages
Chinese (zh)
Other versions
CN106802860A (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

Images

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 useless class detection method and a useless class detection device, wherein the method comprises the following steps: creating an initialized useless class set and a useful class file set; performing iterative matching on the class names in the garbage collection in an initialized useful class file collection so as to remove the class names of the useful classes in the garbage collection; and when the class name of the useful class in the useless class set is removed, outputting the useless class set as a useless class detection result. The method and the device can realize more efficient detection of the useless files and provide a basis for clearing the redundant codes of the system.

Description

Useless class detection method and device
Technical Field
The present application relates to the field of communications, and in particular, to a method and an apparatus for detecting a garbage.
Background
Android is an open source code mobile device operating system based on Linux, and is widely adopted by most electronic products due to the openness and portability of the system. However, with the rapid iteration of the wireless-end Android project, the system code amount is increased sharply, useless classes are gradually accumulated, and inconvenience is caused to the development and maintenance of the system.
Disclosure of Invention
The application provides a useless class detection method, which comprises the following steps:
creating an initialized useless class set and a useful class file set;
performing iterative matching on the class names in the garbage collection in an initialized useful class file collection so as to remove the class names of the useful classes in the garbage collection;
and when the class name of the useful class in the useless class set is removed, outputting the useless class set as a useless class detection result.
Optionally, the creating the initialized garbage class set and the initialized useful class file set includes:
identifying class files in the target directory;
matching the identified class files with a preset useful class sample to detect useless classes and useful classes in the class files;
creating an initialized useful class set based on the detected class name of the useful class;
creating the initialized useful class file set based on the detected class files of the useful class;
creating the initialized garbage collection based on the detected class name of the garbage.
Optionally, the preset useful class sample includes one or more of a preset useful class white list, a useful class directory list, a useful class name feature list and a useful class file feature list;
before identifying the class file in the target directory, the method further comprises:
and clearing the invalid codes in the target directory based on a preset code clearing tool.
Optionally, the iteratively matching the class names in the garbage collection in the initialized useful class file collection to remove the class names of the useful classes in the garbage collection includes:
traversing the garbage collection;
matching the class names in the useless class set with the class files in the useful class file set in sequence;
and when the class names in the useless class set are matched in the class files in the useful class file set, taking the class names as the class names of the useful classes to be moved into the useful class set, and taking the class files corresponding to the class names as the class files of the useful classes to be moved into the useful class file set.
Optionally, the method further includes:
when the class name is taken as the class name of the useful class and moved into the useful class set, and the class file corresponding to the class name is taken as the class file of the useful class and moved into the useful class file set, setting a preset useful class mark as a first mark; the first mark is used for identifying the class name of the useful class which is newly added into the useful class set;
when the class names in the useless class set are not matched in all class files in the useful class file set, setting a preset useful class mark as a second mark; the second mark is used for identifying the class name of the useful class which is not newly added in the useful class set.
Optionally, the method further includes:
reading the preset useful class mark;
judging whether the read useful mark is the first mark or not;
and when the useful class mark is judged to be the first mark, re-traversing the useless class set, and sequentially matching the class names in the useless class set with the class files in the useful class file set until the matching is finished when the useful class mark is judged to be the second mark.
The present application also proposes a garbage detection apparatus, comprising:
the creating module is used for creating an initialized useless class set and an initialized useful class file set;
the matching module is used for carrying out iterative matching on the class names in the useless class set in the initialized useful class file set so as to remove the class names of the useful classes in the useless class set;
and the output module is used for outputting the useless class set as a useless class detection result after the class name of the useful class in the useless class set is removed.
Optionally, the creating module is specifically configured to:
identifying class files in the target directory;
matching the identified class files with a preset useful class sample to detect useless classes and useful classes in the class files;
creating an initialized useful class set based on the detected class name of the useful class;
creating the initialized useful class file set based on the detected class files of the useful class;
creating the initialized garbage collection based on the detected class name of the garbage.
Optionally, the preset useful class sample includes one or more of a preset useful class white list, a useful class directory list, a useful class name feature list and a useful class file feature list;
the creation module is further to:
before identifying the class files in the target directory, clearing invalid codes in the target directory based on a preset code clearing tool.
Optionally, the matching module is specifically configured to:
traversing the garbage collection;
matching the class names in the useless class set with the class files in the useful class file set in sequence;
and when the class names in the useless class set are matched in the class files in the useful class file set, taking the class names as the class names of the useful classes to be moved into the useful class set, and taking the class files corresponding to the class names as the class files of the useful classes to be moved into the useful class file set.
Optionally, the matching module is further configured to:
when the class name is taken as the class name of the useful class and moved into the useful class set, and the class file corresponding to the class name is taken as the class file of the useful class and moved into the useful class file set, setting a preset useful class mark as a first mark; the first mark is used for identifying the class name of the useful class which is newly added into the useful class set;
when the class names in the useless class set are not matched in all class files in the useful class file set, setting a preset useful class mark as a second mark; the second mark is used for identifying the class name of the useful class which is not newly added in the useful class set.
Optionally, the matching module is further configured to:
reading the preset useful class mark;
judging whether the read useful mark is the first mark or not;
and when the useful class mark is judged to be the first mark, re-traversing the useless class set, and sequentially matching the class names in the useless class set with the class files in the useful class file set until the matching is finished when the useful class mark is judged to be the second mark.
According to the method, the initialized useless class set and the useful class file set are created, the class names in the useless class set are subjected to iterative matching in the initialized useful class file set to remove the class names of the useful classes in the useless class set, and after the class names of the useful classes in the useless class set are removed, the useless class set is output as a useless class detection result.
Drawings
Fig. 1 is a flowchart of a garbage detection method according to an embodiment of the present application;
FIG. 2 is a flow chart of iterative matching provided by an embodiment of the present application;
FIG. 3 is a logic block diagram of a garbage detection apparatus according to an embodiment of the present application;
fig. 4 is a hardware structure diagram of a client that carries the garbage detection apparatus according to an embodiment of the present application.
Detailed Description
In the related art, when code cleaning is performed on an android wireless terminal, the code cleaning is usually performed based on a code cleaning tool such as a PMD or a UCDetector.
However, PMD tools are typically only capable of scanning useless proprietary methods, proprietary properties, and useless code and variable definitions within code sections, and are not able to identify their usefulness for other types of code sections, nor are PMD tools capable of class-level scanning.
Although the UCDetector tool can scan useless classes in a standard android project by configuring a useful class white list, the UCDetector does not consider the reference relationship between the classes when scanning the useless classes, so that for the android project providing the API (the android project providing the API has the class which refers to the API), the UCDetector tool cannot accurately define a useful class set, and cannot scan all the useless classes in the project.
Therefore, the existing code cleaning tool cannot meet the code cleaning requirement in the actual working scene.
In view of the above, the present application provides a method for detecting useless classes, which creates an initialized useless class set and a useful class file set, iteratively matches class names in the useless class set in the initialized useful class file set to remove class names of useful classes in the useless class set, and outputs the useless class set as a result of detecting the useless classes after removing the class names of the useful classes in the useless class set.
The present application is described below with reference to specific embodiments and specific application scenarios.
Referring to fig. 1, fig. 1 is a flowchart illustrating a garbage detection method applied to a client according to an embodiment of the present application, where the method includes the following steps:
step 101, creating an initialized useless class set and a useful class file set;
102, performing iterative matching on the class names in the useless class set in an initialized useful class file set to remove the class names of the useful classes in the useless class set;
and 103, when the class name of the useful class in the useless class set is removed, outputting the useless class set as a useless class detection result.
The client can comprise client software for providing useless detection service for software developers; for example, taking the development of the android project as an example, the client software may be a garbage detection tool for providing garbage detection service to the android developer, and the developer may perform garbage detection on the created android project by using the garbage detection tool.
In this embodiment, the hardware environment for carrying the client software is not particularly limited; for example, it may be a PC host, a mobile terminal, or a server.
The following description will be given taking the garbage detection tool, which provides garbage detection service to android developers, by the client software.
In this embodiment, when a developer performs useless class detection on a created android project, the client software may recursively scan all directories under the android project as target directories to identify all class files of the android project.
For the android project, because the android project uses java language as implementation language, class files of the android project are usually system files with the extension name of java, and when identifying the class files, client software can identify the system files with the extension name of java in all directories of the android project.
In addition, before identifying all class files under the android project, the client software can clear invalid codes in the target directory based on a preset code cleaning tool, so that the useless classes can be prevented from being referred to invalid codes such as useless member variables or useless code segments of the useful classes.
In this embodiment, after all the class files of the android project are identified, the client software may match all the identified class files with a preset useful class sample to detect useful classes and useless classes in all the class files of the android project.
Wherein the preset useful class sample may include one or more of a useful class white list, a useful class directory list, a useful class name feature list and a useful class file feature list customized by a developer.
For example, in implementation, a developer may pre-define four variables, a whiteList variable, a usedDirList variable, a usedNamePrefList variable, and a usedContentPrefList variable.
The whiteList variable is a white list of useful classes, and represents a set of classes that do not need to be processed, and the classes in the list are all useful classes. The used dirlist variable is a list of useful class directories, the directories in the list are all useful class directories, and the classes in the useful class directories are all useful classes. The user-added NamePrefList variable is a useful class name feature list, the list comprises class name feature characters of a plurality of useful classes, and if the characters in the list appear in class names, the class is a useful class. The usedContentPrefList variable is a useful class file feature list, which includes feature characters of class files of several useful classes, and if the characters in the list appear in the class file (i.e. the content of the class), the class is a useful class.
Based on the above, when the client software detects the useful classes and the useless classes in all the identified class files, the client software can respectively match all the identified class files in the above four lists, if the matching is successful, the class files are indicated to be the useful classes, and if the matching is unsuccessful, the class files are indicated to be the useless classes. In this way, the client software can detect useful classes and useless classes in all identified class files.
After all the useful classes and useless classes in the identified class files are detected, the client software can create an initialized useful class set based on the class names of all the detected useful classes; the class file can be read based on the file paths of all the useful classes, and an initialized useful class file set (namely a content set of the useful classes) is created based on the read class file; an initialized garbage collection may also be created based on the class names of all the garbage detected.
For the created initialized useless class set, the client software can also record the file paths of all the useless classes in the set, so that in the subsequent iterative matching, when the useless classes in the set become useful classes, the class files of the useless classes are conveniently loaded into the useful class file set based on the file paths.
In this embodiment, since there may be a class name referenced by a class file of a useful class in an initialized garbage collection, and since classes are usually used according to class names in the android project, in the android project of the code specification, once a class name in a certain garbage collection can be matched with a class file in a useful class file collection, a class file corresponding to the class name is always used, and at this time, the class name is referenced by a class file in the useful class file collection, and thus the class file corresponding to the class name is a useful class.
From this perspective, after the client software creates the initialized useful class file set, the useful class file set and the useless class set, the class names of the useful classes in the useless class set can be detected by sequentially matching the class names in the useless class set with the class files in the useful class file set.
Referring to fig. 2, fig. 2 is a flowchart illustrating that the client software performs iterative matching on class names in the useless class set in the useful class file set according to this embodiment.
Before starting to carry out iterative matching on the class names in the useless class set in the useful class file set, the client software can preset a useful class mark for the useful class set.
The useful class mark may include a first mark and a second mark, the first mark is used for identifying the class name of the useful class which is newly added into the useful class set, and the second mark is used for identifying the class name of the useful class which is not newly added into the useful class set.
For example, the client software may preset a flag bit as the flag of the useful class for the set of useful classes, and define two flag values, namely a first flag and a second flag, for the flag bit.
Referring to fig. 2, when iteratively matching a class name in the garbage collection file, the client software may first set a default flag to the useful class flag, where the default flag may be a first flag or a second flag.
For example, the first flag may be a flag T preset for the set of useful classes, the second flag may be a flag F preset for the set of useful classes, and the client software may set the useful class flag to the flag F and also to the flag T when setting the useful class flag to the default flag (the default flag shown in fig. 2 is the flag F).
Referring to fig. 2, after the client software sets the useful class flag as a default flag, the client software may traverse the useless class set, and sequentially match class names in the useless class set with class files in the useful class file set to detect the class names of the useful classes in the useless class set.
On the other hand, if a certain class name in the useless class set is matched in class files in the useful class file set, at this time, the class name is referred to by the useful class file, the class file corresponding to the class name is a useful class, the client software can move the class name as the class name of the useful class into the useful class set, and meanwhile, the class file corresponding to the class name can be moved into the useful class file set as the class file of the useful class based on a pre-recorded file path of the class name.
When the client software moves the class name into the useful class set as the class name of the useful class and moves the class file corresponding to the class name into the useful class file set as the class file of the useful class, the client software may set the useful class flag to be a first flag (the first flag shown in fig. 2 is a flag T) to identify the class name of the useful class newly added into the useful class set.
When the client software sets the useful class mark as a first mark, if the default mark set for the useful class mark by the client software is a second mark, the client software can change the useful class mark from the second mark to the first mark at the moment, and then the client software can read the next class name from the useless class set to be continuously matched with the class files in the useful class file set, and so on until the class names in the useless class set are completely matched. If the default mark set by the client software for the useful class mark is the first mark, the client can directly read the next class name from the useless class set without changing the client at the moment and continuously match with the class files in the useful class file set, and so on until the class names in the useless class set are matched.
On the other hand, if a class name in the useless class set is not matched with a class file in the useful class file set, the class name is not referred by the class file of the useful class at this time, the class file corresponding to the class name is a useless class, the client software can read the next class name from the useless class set and continue to match with the class file in the useful class file set, and so on until the class names in the useless class set are all matched.
Of course, if none of the class files in the useful class file set matches the class name in the useless class set, at this time, none of the class names in the useless class set is referenced by the class file of the useful class, and all of the class files corresponding to the class name in the useless class set are useless classes, in this case, the client may set the useful class flag to be a second flag (the second flag shown in fig. 2 is flag F) to identify the class name of the useful class set to which no useful class is newly added.
When the client software sets the useful class flag to be the second flag, if the useful class flag is set to be the first flag by the client as a default, the client may change the useful class flag from the first flag to the second flag at this time, and if the useful class flag is set to be the second flag by the client as a default, the client may not change at this time, and this round of iteration ends at this time.
The above describes a round of iterative process of the client software in iteratively matching the class names in the garbage collection in the useful class file collection in conjunction with fig. 2.
In this embodiment, after a round of iteration is finished, if a class name of a useful class is newly added to a useful class set, at this time, a class name used by a class file of the newly added useful class, that is, a class name referred by the class file of the newly added useful class, may still exist in the useless class set.
Thus, in this case, if the class name of the useful class is newly added to the useful class set, the client software may continue to start the next iteration until it stops when no more new class names of the useful class are added to the useless class set.
Referring to fig. 2, after a round of iteration is finished, the client software may read the useful class mark, and determine whether the read useful mark is the first mark.
If the client software judges that the useful class mark is the first mark, the class name of the useful class still possibly exists in the useless class set at the moment, the client software can perform the next iteration according to the iteration process, set the useful class mark as a default mark, traverse the useless class set again, and match the class name in the useless class set with the class file in the useful class file set in sequence, and the specific process is not repeated.
In this way, the client software can continuously move the class names of the useful classes in the garbage collection out of the garbage collection and move the useful classes into the useful class collection through repeated iteration.
Referring to fig. 2 again, when the client software finally determines that the read useful mark is the second mark after repeated iteration, all the class names of the useful classes in the garbage class set are moved into the useful class set, at this time, the iterative matching is finished, and the remaining class names in the garbage class set are the final garbage class detection result.
In this case, the client software may output the current garbage set to the developer as a garbage detection result, and the developer may remove the garbage in the current android project based on the garbage detection result output by the client software.
Therefore, the reference relation between the class name of the useless class and the class file of the useful class can be fully considered, and the problem that all the useless classes in the android project cannot be scanned due to the fact that the UCDetector tool cannot define the useful class set inaccurately because the reference relation between the classes is not considered can be avoided. Therefore, useless files can be detected more efficiently.
In addition, it should be noted that, in the flow shown in fig. 2, when the client starts to perform iterative matching on the class name in the useless class set in the useful class file set, in another implementation manner, a default flag may not be set for the useful class flag, but a subsequent matching step is directly performed, the useless class set is traversed, the class name in the useless class set is sequentially matched with the class files in the useful class file set, until one round of iteration is finished, a first flag or a second flag is set for the flag bit according to an iteration result, and then the client software may determine whether to start a next round of iteration by judging whether the useful class flag is the first flag.
For example, the client software may still preset a flag bit as the useful class flag for the useful class set, and define two flag values, namely a first flag and a second flag, for the flag bit, and only retain the flag bit when the iterative matching starts, and the client software does not set a specific flag value for the flag, but directly performs subsequent matching steps until a round of iteration is completed, and then sets the first flag or the second flag for the flag bit according to the iteration result, which is not described again.
In the above embodiment, the initialized useless class set and the useful class file set are created, the class names in the useless class set are iteratively matched in the initialized useful class file set to remove the class names of the useful classes in the useless class set, and after the class names of the useful classes in the useless class set are removed, the useless class set is output as the useless class detection result.
Corresponding to the method embodiment, the application also provides an embodiment of the device.
Referring to fig. 3, the present application provides a garbage detection apparatus 30 applied to a client; referring to fig. 4, the hardware architecture related to the client that carries the idle detection device 30 generally includes a CPU, a memory, a non-volatile memory, a network interface, an internal bus, and the like; in software implementation, the garbage detection apparatus 30 may be generally understood as a computer program loaded in a memory, and a logic apparatus formed by combining software and hardware after being executed by a CPU, where the apparatus 30 includes:
a creating module 301, configured to create an initialized garbage class set and a useful class file set;
a matching module 302, configured to perform iterative matching on the class names in the garbage collection in an initialized useful class file collection to remove the class names of the useful classes in the garbage collection;
an output module 303, configured to output the garbage collection as a garbage detection result after the class name of the useful class in the garbage collection is removed.
In this embodiment, the creating module 301 is specifically configured to:
identifying class files in the target directory;
matching the identified class files with a preset useful class sample to detect useless classes and useful classes in the class files;
creating an initialized useful class set based on the detected class name of the useful class;
creating the initialized useful class file set based on the detected class files of the useful class;
creating the initialized garbage collection based on the detected class name of the garbage.
In this embodiment, the preset useful class sample includes one or more of a preset useful class white list, a useful class directory list, a useful class name feature list and a useful class file feature list;
the creating module 301 is further configured to:
before identifying the class files in the target directory, clearing invalid codes in the target directory based on a preset code clearing tool.
In this embodiment, the matching module 302 is specifically configured to:
traversing the garbage collection;
matching the class names in the useless class set with the class files in the useful class file set in sequence;
and when the class names in the useless class set are matched in the class files in the useful class file set, taking the class names as the class names of the useful classes to be moved into the useful class set, and taking the class files corresponding to the class names as the class files of the useful classes to be moved into the useful class file set.
In this embodiment, the matching module 302 is further configured to:
when the class name is taken as the class name of the useful class and moved into the useful class set, and the class file corresponding to the class name is taken as the class file of the useful class and moved into the useful class file set, setting a preset useful class mark as a first mark; the first mark is used for identifying the class name of the useful class which is newly added into the useful class set;
when the class names in the useless class set are not matched in all class files in the useful class file set, setting a preset useful class mark as a second mark; the second mark is used for identifying the class name of the useful class which is not newly added in the useful class set.
In this embodiment, the matching module 302 is further configured to:
reading the preset useful class mark;
judging whether the read useful mark is the first mark or not;
and when the useful class mark is judged to be the first mark, re-traversing the useless class set, and sequentially matching the class names in the useless class set with the class files in the useful class file set until the matching is finished when the useful class mark is judged to be the second mark.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the scope of protection of the present application.

Claims (10)

1. A garbage detection method, comprising:
matching class files identified from a target directory with a preset useful class sample to detect useless classes and useful classes in the class files, and creating an initialized useless class set, a useful class set and a useful class file set based on the detection result;
traversing the useless class set, and sequentially matching class names in the useless class set with class files in the useful class file set;
when the class names in the useless class set are matched in the class files in the useful class file set, removing the class names from the useless class set as the class names of the useful classes, moving the class names into the useful class set, and moving the class files corresponding to the class names into the useful class file set as the class files of the useful classes;
and when the class name of the useful class in the useless class set is removed, outputting the useless class set as a useless class detection result.
2. The method of claim 1, wherein creating an initialized set of garbage classes and a set of useful class files based on the result of the detecting comprises:
creating an initialized useful class set based on the detected class name of the useful class;
creating the initialized useful class file set based on the detected class files of the useful class;
creating the initialized garbage collection based on the detected class name of the garbage.
3. The method of claim 2, wherein the predetermined useful class samples comprise one or more of a predetermined useful class white list, a useful class directory list, a useful class name feature list, and a useful class file feature list;
before identifying the class file in the target directory, the method further comprises:
and clearing the invalid codes in the target directory based on a preset code clearing tool.
4. The method of claim 2, further comprising:
when the class name is taken as the class name of the useful class and moved into the useful class set, and the class file corresponding to the class name is taken as the class file of the useful class and moved into the useful class file set, setting a preset useful class mark as a first mark; the first mark is used for identifying the class name of the useful class which is newly added into the useful class set;
when the class names in the useless class set are not matched in all class files in the useful class file set, setting a preset useful class mark as a second mark; the second mark is used for identifying the class name of the useful class which is not newly added in the useful class set.
5. The method of claim 4, further comprising:
reading the preset useful class mark;
judging whether the read useful class mark is the first mark or not;
and when the useful class mark is judged to be the first mark, re-traversing the useless class set, and sequentially matching the class names in the useless class set with the class files in the useful class file set until the matching is finished when the useful class mark is judged to be the second mark.
6. A garbage detection apparatus, comprising:
the creating module is used for matching the class files identified from the target directory with a preset useful class sample so as to detect the useless classes and the useful classes in the class files, and creating an initialized useless class set, a useful class set and a useful class file set based on the detection result;
the matching module is used for traversing the useless class set and matching the class names in the useless class set with the class files in the useful class file set in sequence; when the class names in the useless class set are matched in the class files in the useful class file set, removing the class names from the useless class set as the class names of the useful classes, moving the class names into the useful class set, and moving the class files corresponding to the class names into the useful class file set as the class files of the useful classes;
and the output module is used for outputting the useless class set as a useless class detection result after the class name of the useful class in the useless class set is removed.
7. The apparatus of claim 6, wherein the creation module is specifically configured to:
creating an initialized useful class set based on the detected class name of the useful class;
creating the initialized useful class file set based on the detected class files of the useful class;
creating the initialized garbage collection based on the detected class name of the garbage.
8. The apparatus of claim 7, wherein the predetermined useful class samples comprise one or more of a predetermined useful class white list, a useful class directory list, a useful class name feature list, and a useful class file feature list;
the creation module is further to:
before identifying the class files in the target directory, clearing invalid codes in the target directory based on a preset code clearing tool.
9. The apparatus of claim 7, wherein the matching module is further configured to:
when the class name is taken as the class name of the useful class and moved into the useful class set, and the class file corresponding to the class name is taken as the class file of the useful class and moved into the useful class file set, setting a preset useful class mark as a first mark; the first mark is used for identifying the class name of the useful class which is newly added into the useful class set;
when the class names in the useless class set are not matched in all class files in the useful class file set, setting a preset useful class mark as a second mark; the second mark is used for identifying the class name of the useful class which is not newly added in the useful class set.
10. The apparatus of claim 9, wherein the matching module is further configured to:
reading the preset useful class mark;
judging whether the read useful class mark is the first mark or not;
and when the useful class mark is judged to be the first mark, re-traversing the useless class set, and sequentially matching the class names in the useless class set with the class files in the useful class file set until the matching is finished when the useful class mark is judged to be the 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 CN106802860A (en) 2017-06-06
CN106802860B true 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)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107358099B (en) * 2017-06-09 2020-05-05 南京邮电大学 Useless variable detection method based on LLVM intermediate representation program slicing technology
CN110990296B (en) * 2019-12-20 2023-10-13 抖音视界有限公司 Identification method of class component, server, terminal and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0913769A3 (en) * 1997-10-31 1999-12-01 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
EP0913769A3 (en) * 1997-10-31 1999-12-01 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

Also Published As

Publication number Publication date
CN106802860A (en) 2017-06-06

Similar Documents

Publication Publication Date Title
US10705748B2 (en) Method and device for file name identification and file cleaning
CN108628751B (en) Useless dependency item detection method and device
CN108845930B (en) Interface operation test method and device, storage medium and electronic device
CN106445476B (en) Code change information determination method and device and electronic equipment
CN113067743B (en) Flow rule extraction method, device, system and storage medium
US20060277402A1 (en) System startup method
CN106469049B (en) File scanning method and device
CN107783766B (en) Method and device for cleaning files of application program
US10540325B2 (en) Method and device for identifying junk picture files
WO2016000541A1 (en) Method and device for automatically identifying junk files
US20190005057A1 (en) Methods and Devices for File Folder Path Identification and File Folder Cleaning
CN110472165B (en) URL extraction method, device, equipment and computer readable storage medium
CN112035359A (en) Program testing method, program testing device, electronic equipment and storage medium
CN106406913B (en) Method and system for extracting codes from project
CN106802860B (en) Useless class detection method and device
JP2021002326A (en) Refinement of repair patterns for static analysis violations in software programs
CN113568604B (en) Method and device for updating wind control strategy and computer readable storage medium
WO2021183382A1 (en) Graph-based method for inductive bug localization
CN111782516A (en) Code testing method and device and storage medium
CN113821496B (en) Database migration method, system, device and computer readable storage medium
CN104572943A (en) Installation-free program cleaning method and device
CN109635175B (en) Page data splicing method and device, readable storage medium and electronic equipment
CN114237976A (en) Data acquisition method and device
CN111151008B (en) Verification method and device for game operation data, configuration background and medium
CN108132971B (en) Analysis method and device for database fragment files

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

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.

TR01 Transfer of patent right