File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java | File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java | |||
Method name: void addGetFieldHandlerMethod(ClassFile)
|
Method name: void addSetFieldHandlerMethod(ClassFile)
|
|||
Number of AST nodes: 12 | Number of AST nodes: 13 | |||
1 | ConstPool cp = classfile.getConstPool();↵ | 1 | ConstPool cp = classfile.getConstPool();↵ | |
2 | int this_class_index = cp.getThisClassInfo();↵ | 2 | int this_class_index = cp.getThisClassInfo();↵ | |
3 | MethodInfo minfo = new MethodInfo(cp, GETFIELDHANDLER_METHOD_NAME,↵ | 3 | MethodInfo minfo = new MethodInfo(cp, SETFIELDHANDLER_METHOD_NAME,↵ | |
4 | GETFIELDHANDLER_METHOD_DESCRIPTOR);↵ | 4 | SETFIELDHANDLER_METHOD_DESCRIPTOR);↵ | |
5 | /* local variable | this | */↵ | 5 | /* local variables | this | callback | */↵ | |
6 | Bytecode code = new Bytecode(cp, 2, 1);↵ | 6 | Bytecode code = new Bytecode(cp, 3, 3);↵ | |
7 | // aload_0 // load this↵ | 7 | // aload_0 // load this↵ | |
8 | code.addAload(0);↵ | 8 | code.addAload(0);↵ | |
9 | // ge↵ | 9 | // aload_1 // load callback↵ | |
10 | code.addAload(1);↵ | |||
10 | tfield // get field "$JAVASSIST_CALLBACK" defined already↵ | 11 | // putfield // put field "$JAVASSIST_CALLBACK" defined already↵ | |
11 | code.addOpcode(Opcode.GETFIELD);↵ | 12 | code.addOpcode(Opcode.PUTFIELD);↵ | |
12 | int field_index = cp.addFieldrefInfo(this_class_index,↵ | 13 | int field_index = cp.addFieldrefInfo(this_class_index,↵ | |
13 | HANDLER_FIELD_NAME, HANDLER_FIELD_DESCRIPTOR);↵ | 14 | HANDLER_FIELD_NAME, HANDLER_FIELD_DESCRIPTOR);↵ | |
14 | code.addIndex(field_index);↵ | 15 | code.addIndex(field_index);↵ | |
15 | // areturn // return the value of the field↵ | 16 | // return↵ | |
16 | code.addOpcode(Opcode.ARETURN);↵ | 17 | code.addOpcode(Opcode.RETURN);↵ | |
17 | minfo.setCodeAttribute(code.toCodeAttribute());↵ | 18 | minfo.setCodeAttribute(code.toCodeAttribute());↵ | |
18 | minfo.setAccessFlags(AccessFlag.PUBLIC);↵ | 19 | minfo.setAccessFlags(AccessFlag.PUBLIC);↵ | |
19 | classfile.addMethod(minfo); | 20 |
| |
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.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 113 |
Number of mapped statements | 12 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | ConstPool cp = classfile.getConstPool(); | 1 | ConstPool cp = classfile.getConstPool(); | ||||||||||||||
2 | int this_class_index = cp.getThisClassInfo(); | 2 | int this_class_index = cp.getThisClassInfo(); | ||||||||||||||
3 | MethodInfo minfo = new MethodInfo(cp, GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR); |
| 3 | MethodInfo minfo = new MethodInfo(cp, SETFIELDHANDLER_METHOD_NAME, SETFIELDHANDLER_METHOD_DESCRIPTOR); | |||||||||||||
4 | Bytecode code = new Bytecode(cp, 2, 1); |
| 4 | Bytecode code = new Bytecode(cp, 3, 3); | |||||||||||||
5 | code.addAload(0); | 5 | code.addAload(0); | ||||||||||||||
| 6 | code.addAload(1); | |||||||||||||||
6 | code.addOpcode(Opcode.GETFIELD); |
| 7 | code.addOpcode(Opcode.PUTFIELD); | |||||||||||||
7 | int field_index = cp.addFieldrefInfo(this_class_index, HANDLER_FIELD_NAME, HANDLER_FIELD_DESCRIPTOR); | 8 | int field_index = cp.addFieldrefInfo(this_class_index, HANDLER_FIELD_NAME, HANDLER_FIELD_DESCRIPTOR); | ||||||||||||||
8 | code.addIndex(field_index); | 9 | code.addIndex(field_index); | ||||||||||||||
9 | code.addOpcode(Opcode.ARETURN); |
| 10 | code.addOpcode(Opcode.RETURN); | |||||||||||||
10 | minfo.setCodeAttribute(code.toCodeAttribute()); | 11 | minfo.setCodeAttribute(code.toCodeAttribute()); | ||||||||||||||
11 | minfo.setAccessFlags(AccessFlag.PUBLIC); | 12 | minfo.setAccessFlags(AccessFlag.PUBLIC); | ||||||||||||||
12 | classfile.addMethod(minfo); | 13 | classfile.addMethod(minfo); |
Row | Violation |
---|---|
1 | Clone fragment #1 returns variables , while Clone fragment #2 returns variables code |