File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java | |||
Method name: void determineDependencies(Vector, Vector)
|
Method name: void determineDependencies(Vector, Vector)
|
|||
Number of AST nodes: 23 | Number of AST nodes: 23 | |||
1 | while (toAnalyze.size() != 0 && count++ < maxCount) {↵ | |||
2 | DependencyVisitor dependencyVisitor = new DependencyVisitor();↵ | |||
3 | for (Enumeration e = toAnalyze.keys(); e.hasMoreElements();) {↵ | |||
1 | String classname = (String) e.nextElement();↵ | 4 | String classname = (String) e.nextElement();↵ | |
2 | dependencies.put(classname, classname);↵ | 5 | dependencies.put(classname, classname);↵ | |
3 | try {↵ | 6 | try {↵ | |
4 | File container = getClassContainer(classname);↵ | 7 | File container = getClassContainer(classname);↵ | |
5 | if (container == null) {↵ | 8 | if (container == null) {↵ | |
6 | continue;↵ | 9 | continue;↵ | |
7 | }↵ | 10 | }↵ | |
8 | containers.put(container, container);↵ | 11 | containers.put(container, container);↵ | |
9 | ZipFile zipFile = null;↵ | 12 | ↵ | |
10 | InputStream inStream = null;↵ | |||
11 | try {↵ | |||
12 | ↵ | 13 | ClassParser parser = null;↵ | |
13 | if (container.getName().endsWith(".class")) {↵ | 14 | if (container.getName().endsWith(".class")) {↵ | |
14 | inStream = new FileInputStream(container.getPath());↵ | 15 | parser = new ClassParser(container.getPath());↵ | |
15 | } else {↵ | 16 | } else {↵ | |
16 | zipFile = new ZipFile(container.getPath());↵ | 17 | ↵ | |
17 | String entryName↵ | |||
18 | ↵ | 18 | parser = new ClassParser(container.getPath(),↵ | |
19 | = classname.replace('.', '/') + ".class";↵ | 19 | classname.replace('.', '/') + ".class");↵ | |
20 | ↵ | 20 | }↵ | |
21 | ZipEntry entry = new ZipEntry(entryName);↵ | 21 | ↵ | |
22 | inStream↵ | |||
23 | = zipFile.getInputStream(entry);↵ | |||
24 | ↵ | 22 | JavaClass javaClass = parser.parse();↵ | |
23 | DescendingVisitor traverser↵ | |||
24 | = new DescendingVisitor(javaClass, dependencyVisitor);↵ | |||
25 | traverser.visit();↵ | |||
26 | } catch (IOException ioe) {↵ | |||
25 | }↵ | 27 | ↵ | |
26 | ClassFile classFile = new ClassFile();↵ | 28 | // ignore↵ | |
29 | }↵ | |||
27 | ↵ | 30 | }↵ | |
28 | classFile.read(inStream);↵ | 31 | toAnalyze.clear();↵ | |
29 | Vector dependencyList = classFile.getClassRefs();↵ | 32 | // now recover all the dependenc↵ | |
30 | ↵ | 33 | ies collected and add to the list.↵ | |
31 | Enumeration depEnum = dependencyList.elements();↵ | 34 | Enumeration depsEnum = dependencyVis↵ | |
32 | ↵ | 35 | itor.getDependencies();↵ | |
33 | while (depEnum.hasMoreElements()) {↵ | 36 | while (depsEnum.hasMoreElements()) {↵ | |
34 | String dependency = (String) depEnum.nextElement();↵ | 37 | String className = (String) depsEnum.nextElement();↵ | |
35 | analyzedDeps.put(dependency, dependency);↵ | 38 | ↵ | |
36 | }↵ | |||
37 | } finally {↵ | |||
38 | if (inStream != null) {↵ | |||
39 | inStream.close();↵ | |||
40 | }↵ | |||
41 | if (zipFile != null) {↵ | |||
42 | zipFile.close();↵ | |||
43 | }↵ | |||
44 | }↵ | |||
45 | } catch (IOException ioe) {↵ | |||
46 | // ignore↵ | |||
47 | ↵ | 39 | if (!dependencies.containsKey(className)) {↵ | |
40 | toAnalyze.put(className, className);↵ | |||
41 | }↵ | |||
42 | }↵ | |||
48 | } | 43 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.5 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 25 |
Number of mapped statements | 1 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 7 |
Time elapsed for statement mapping (ms) | 2.3 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||
---|---|---|---|---|---|---|---|
|
| 17 | continue; | ||||
23 | if (container.getName().endsWith(".class")) | 20 | if (container.getName().endsWith(".class")) | ||||
|
| 21 | parser = new ClassParser(container.getPath()); | ||||
24 | inStream = new FileInputStream(container.getPath()); |
| | ||||
else | | ||||||
|
| 22 | parser = new ClassParser(container.getPath(), classname.replace('.', '/') + ".class"); | ||||
25 | zipFile = new ZipFile(container.getPath()); | | |||||
26 | String entryName = classname.replace('.', '/') + ".class"; | | |||||
27 | ZipEntry entry = new ZipEntry(entryName); | | |||||
28 | inStream = zipFile.getInputStream(entry); |
| |
Row | Violation |
---|---|
1 | Unmatched continue; |
2 | Unmatched statement inStream=new FileInputStream(container.getPath()); cannot be moved, because it updates a variable modified in other unmapped statements |
3 | Unmatched statement inStream=zipFile.getInputStream(entry); cannot be moved, because it updates a variable modified in other unmapped statements |
4 | Unmatched statement parser=new ClassParser(container.getPath()); cannot be moved, because it updates a variable modified in other unmapped statements |
5 | Unmatched statement parser=new ClassParser(container.getPath(),classname.replace('.','/') + ".class"); cannot be moved, because it updates a variable modified in other unmapped statements |