File path: /jruby-1.4.0/src/org/jruby/internal/runtime/methods/ReflectionMethodFactory.java | File path: /jruby-1.4.0/src/org/jruby/runtime/callback/ReflectionCallbackFactory.java | |||
Method name: CompiledBlockCallback getBlockCallback(String, Object)
|
Method name: CompiledBlockCallback getBlockCallback(String, Object)
|
|||
Number of AST nodes: 4 | Number of AST nodes: 3 | |||
1 | try {↵ | 1 | try {↵ | |
2 | Class scriptClass = scriptObject.getClass();↵ | |||
3 | final Method blockMethod = scriptClass.getMethod(method, scriptClass, ThreadContext.class, IRubyObject.class, IRubyObject.class);↵ | 2 | final Method blockMethod = scriptObject.getClass().getMethod(method, new Class[]{ThreadContext.class, IRubyObject.class, IRubyObject.class});↵ | |
4 | return new CompiledBlockCallback() {↵ | 3 | return new CompiledBlockCallback() {↵ | |
5 | public IRubyObject call(ThreadContext context, IRubyObject self, IRubyObject args) {↵ | 4 | public IRubyObject call(ThreadContext context, IRubyObject self, IRubyObject args) {↵ | |
6 | try {↵ | 5 | try {↵ | |
7 | return (IRubyObject)blockMethod.invoke(null, scriptObject, context, self, args);↵ | 6 | return (IRubyObject)blockMethod.invoke(scriptObject, new Object[]{context, self, args});↵ | |
8 | } catch (IllegalAccessException ex) {↵ | 7 | } catch (IllegalAccessException ex) {↵ | |
9 | throw new RuntimeException(ex);↵ | 8 | throw new RuntimeException(ex);↵ | |
10 | } catch (IllegalArgumentException ex) {↵ | 9 | } catch (IllegalArgumentException ex) {↵ | |
11 | throw new RuntimeException(ex);↵ | 10 | throw new RuntimeException(ex);↵ | |
12 | } catch (InvocationTargetException ex) {↵ | 11 | } catch (InvocationTargetException ex) {↵ | |
13 | Throwable cause = ex.getCause();↵ | 12 | Throwable cause = ex.getCause();↵ | |
14 | if (cause instanceof RuntimeException) {↵ | 13 | if (cause instanceof RuntimeException) {↵ | |
15 | throw (RuntimeException) cause;↵ | 14 | throw (RuntimeException) cause;↵ | |
16 | } else if (cause instanceof Error) {↵ | 15 | } else if (cause instanceof Error) {↵ | |
17 | throw (Error) cause;↵ | 16 | throw (Error) cause;↵ | |
18 | } else {↵ | 17 | } else {↵ | |
19 | throw new RuntimeException(ex);↵ | 18 | throw new RuntimeException(ex);↵ | |
20 | }↵ | 19 | }↵ | |
21 | }↵ | 20 | }↵ | |
22 | }↵ | 21 | }↵ | |
23 | };↵ | 22 | };↵ | |
24 | } catch (NoSuchMethodException nsme) {↵ | 23 | } catch (NoSuchMethodException nsme) {↵ | |
25 | throw new RuntimeException(nsme);↵ | 24 | throw new RuntimeException(nsme);↵ | |
26 | } | 25 |
| |
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.9 |
Clones location | Clones are in different classes |
Number of node comparisons | 12 |
Number of mapped statements | 2 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 13.2 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | try | 1 | try | |||||||||||||
| 2 | final Method blockMethod = scriptObject.getClass().getMethod(method, new Class[] {ThreadContext.class, IRubyObject.class, IRubyObject.class}); | ||||||||||||||
2 | Class scriptClass = scriptObject.getClass(); | | ||||||||||||||
3 | final Method blockMethod = scriptClass.getMethod(method, scriptClass, ThreadContext.class, IRubyObject.class, IRubyObject.class); |
| | |||||||||||||
4 | return new CompiledBlockCallback() {...}; |
| 3 | return new CompiledBlockCallback() {...}; |
Row | Violation |
---|---|
1 | Unmatched statement final Method blockMethod=scriptClass.getMethod(method,scriptClass,ThreadContext.class,IRubyObject.class,IRubyObject.class); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
2 | Expression blockMethod.invoke(null,scriptObject,context,self,args) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression blockMethod.invoke(scriptObject,new Object[]{context,self,args}) cannot be parameterized, because it has dependencies to/from statements that will be extracted |