You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Emmanuel Bourg (JIRA)" <ji...@apache.org> on 2014/04/24 14:15:18 UTC
[jira] [Updated] (BCEL-20) InstructionList.copy() fails with Select
instruction.
[ https://issues.apache.org/jira/browse/BCEL-20?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Bourg updated BCEL-20:
-------------------------------
Priority: Major
Environment: (was: Operating System: Linux
Platform: All)
Fix Version/s: 5.2
Priority: (was: P3)
Severity: (was: normal)
> InstructionList.copy() fails with Select instruction.
> -----------------------------------------------------
>
> Key: BCEL-20
> URL: https://issues.apache.org/jira/browse/BCEL-20
> Project: Commons BCEL
> Issue Type: Bug
> Components: Main
> Affects Versions: 5.0
> Reporter: wombat
> Assignee: Apache Commons Developers
> Fix For: 5.2
>
>
> 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.
> */
--
This message was sent by Atlassian JIRA
(v6.2#6252)