File path: /jruby-1.4.0/src/org/jruby/java/invokers/ConstructorInvoker.java | File path: /jruby-1.4.0/src/org/jruby/java/invokers/MethodInvoker.java | |||
Method name: void createJavaCallables(Ruby)
|
Method name: void createJavaMethods(Ruby)
|
|||
Number of AST nodes: 23 | Number of AST nodes: 23 | |||
1 | if (!initialized) { // read-volatile↵ | 1 | if (!initialized) { // read-volatile↵ | |
2 | if (ctors != null) {↵ | 2 | if (methods != null) {↵ | |
3 | if (ctors.length == 1) {↵ | 3 | if (methods.length == 1) {↵ | |
4 | javaCallable = JavaConstructor.create(runtime, ctors[0]);↵ | 4 | javaCallable = JavaMethod.create(runtime, methods[0]);↵ | |
5 | } else {↵ | 5 | } else {↵ | |
6 | Map methodsMap = new HashMap();↵ | 6 | Map methodsMap = new HashMap();↵ | |
7 | int maxArity = 0;↵ | 7 | int maxArity = 0;↵ | |
8 | for (Constructor ctor: ctors) {↵ | 8 | for (Method method: methods) {↵ | |
9 | // TODO: deal with varargs↵ | 9 | // TODO: deal with varargs↵ | |
10 | int arity = ctor.getParameterTypes().length;↵ | 10 | int arity = method.getParameterTypes().length;↵ | |
11 | maxArity = Math.max(arity, maxArity);↵ | 11 | maxArity = Math.max(arity, maxArity);↵ | |
12 | List<JavaConstructor> methodsForArity = (ArrayList<JavaConstructor>)methodsMap.get(arity);↵ | 12 | List<JavaMethod> methodsForArity = (ArrayList<JavaMethod>)methodsMap.get(arity);↵ | |
13 | if (methodsForArity == null) {↵ | 13 | if (methodsForArity == null) {↵ | |
14 | methodsForArity = new ArrayList<JavaConstructor>();↵ | 14 | methodsForArity = new ArrayList<JavaMethod>();↵ | |
15 | methodsMap.put(arity,methodsForArity);↵ | 15 | methodsMap.put(arity,methodsForArity);↵ | |
16 | }↵ | 16 | }↵ | |
17 | methodsForArity.add(JavaConstructor.create(runtime,ctor));↵ | 17 | methodsForArity.add(JavaMethod.create(runtime,method));↵ | |
18 | }↵ | 18 | }↵ | |
19 | javaCallables = new JavaConstructor[maxArity + 1][];↵ | 19 | javaCallables = new JavaMethod[maxArity + 1][];↵ | |
20 | for (Iterator<Map.Entry> iter = methodsMap.entrySet().iterator(); iter.hasNext();) {↵ | 20 | for (Iterator<Map.Entry> iter = methodsMap.entrySet().iterator(); iter.hasNext();) {↵ | |
21 | Map.Entry entry = iter.next();↵ | 21 | Map.Entry entry = iter.next();↵ | |
22 | List<JavaConstructor> ctorsForArity = (List<JavaConstructor>)entry.getValue();↵ | 22 | List<JavaMethod> methodsForArity = (List<JavaMethod>)entry.getValue();↵ | |
23 | JavaConstructor[] methodsArray = ctorsForArity.toArray(new JavaConstructor[ctorsForArity.size()]);↵ | 23 | JavaMethod[] methodsArray = methodsForArity.toArray(new JavaMethod[methodsForArity.size()]);↵ | |
24 | javaCallables[((Integer)entry.getKey()).intValue()] = methodsArray;↵ | 24 | javaCallables[((Integer)entry.getKey()).intValue()] = methodsArray;↵ | |
25 | }↵ | 25 | }↵ | |
26 | }↵ | 26 | }↵ | |
27 | ctors = null;↵ | 27 | methods = null;↵ | |
28 | // initialize cache of parameter types to method↵ | 28 | // initialize cache of parameter types to method↵ | |
29 | cache = new ConcurrentHashMap();↵ | 29 | cache = new ConcurrentHashMap();↵ | |
30 | }↵ | 30 | }↵ | |
31 | initialized = true; // write-volatile↵ | 31 | initialized = true; // write-volatile↵ | |
32 | } | 32 |
| |
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.7 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 19 |
Number of mapped statements | 3 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 27.8 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 8 | int arity = method.getParameterTypes().length; | ||||||||||||
8 | int arity = ctor.getParameterTypes().length; |
| | ||||||||||||
9 | maxArity = Math.max(arity, maxArity); | 9 | maxArity = Math.max(arity, maxArity); | ||||||||||||
|
| 10 | List<JavaMethod> methodsForArity = (ArrayList<JavaMethod>)methodsMap.get(arity); | ||||||||||||
10 | List<JavaConstructor> methodsForArity = (ArrayList<JavaConstructor>)methodsMap.get(arity); |
| | ||||||||||||
11 | if (methodsForArity == null) |
| 11 | if (methodsForArity == null) | |||||||||||
|
| 12 | methodsForArity = new ArrayList<JavaMethod>(); | ||||||||||||
12 | methodsForArity = new ArrayList<JavaConstructor>(); |
| | ||||||||||||
13 | methodsMap.put(arity, methodsForArity); |
| 13 | methodsMap.put(arity, methodsForArity); |
Row | Violation |
---|---|
1 | Unmatched statement int arity=method.getParameterTypes().length; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement int arity=ctor.getParameterTypes().length; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement List<JavaMethod> methodsForArity=(ArrayList<JavaMethod>)methodsMap.get(arity); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement List<JavaConstructor> methodsForArity=(ArrayList<JavaConstructor>)methodsMap.get(arity); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Type java.util.List<org.jruby.javasupport.JavaConstructor> of variable methodsForArity does not match with type java.util.List<org.jruby.javasupport.JavaMethod> of variable methodsForArity |
6 | Unmatched statement methodsForArity=new ArrayList<JavaMethod>(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement methodsForArity=new ArrayList<JavaConstructor>(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Type java.util.List<org.jruby.javasupport.JavaConstructor> of variable methodsForArity does not match with type java.util.List<org.jruby.javasupport.JavaMethod> of variable methodsForArity |