You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by bu...@apache.org on 2003/04/05 15:48:08 UTC
DO NOT REPLY [Bug 18731] New: -
InstructionList.copy() fails with Select instruction.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18731>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18731
InstructionList.copy() fails with Select instruction.
Summary: InstructionList.copy() fails with Select instruction.
Product: BCEL
Version: 5.0RC1
Platform: All
OS/Version: Linux
Status: NEW
Severity: Normal
Priority: Other
Component: Main
AssignedTo: bcel-dev@jakarta.apache.org
ReportedBy: wombat@uni.de
The implementation of InstructionList.copy() works on the internal targets
fields of the select instructions:
(InstructionList.java line 1110)
InstructionHandle[] itargets = ((Select)bi).getTargets();
InstructionHandle[] ctargets = ((Select)bc).getTargets();
But because bc is created from bi by cloning bi, both refer to the same target
array.
Changing ctargets also changes itargets.
The reason for this is, that Select does not override clone.
The following patch fixes this problem:
Index: Select.java
===================================================================
RCS file:
/home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/generic/Select.java,v
retrieving revision 1.2
diff -u -r1.2 Select.java
--- Select.java 26 Apr 2002 09:30:11 -0000 1.2
+++ Select.java 5 Apr 2003 13:37:54 -0000
@@ -227,6 +227,16 @@
return false;
}
+ protected Object clone() throws CloneNotSupportedException {
+ Select result = (Select) super.clone();
+
+ result.match = (int[]) result.match.clone();
+ result.indices = (int[]) result.indices.clone();
+ result.targets = (InstructionHandle[]) result.targets.clone();
+
+ return result;
+ }
+
/**
* Inform targets that they're not targeted anymore.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org