You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2015/08/28 00:55:49 UTC

svn commit: r1698238 - in /commons/proper/bcel/trunk/src: changes/changes.xml main/java/org/apache/commons/bcel6/generic/Select.java

Author: sebb
Date: Thu Aug 27 22:55:48 2015
New Revision: 1698238

URL: http://svn.apache.org/r1698238
Log:
BCEL-261 Select constructor allows partially constructed instance to escape. Re-ordered code to delay the escape

Modified:
    commons/proper/bcel/trunk/src/changes/changes.xml
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Select.java

Modified: commons/proper/bcel/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/changes/changes.xml?rev=1698238&r1=1698237&r2=1698238&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/changes/changes.xml (original)
+++ commons/proper/bcel/trunk/src/changes/changes.xml Thu Aug 27 22:55:48 2015
@@ -63,6 +63,7 @@ The <action> type attribute can be add,u
 
   <body>
     <release version="6.0" date="TBA" description="Major release with Java 7 and 8 support">
+      <action issue="BCEL-261" type="fix">Select constructor allows partially constructed instance to escape. Re-ordered code to delay the escape.</action>
       <action issue="BCEL-259" type="fix">Minor doc error in BranchInstruction.java</action>
       <action issue="BCEL-260" type="fix">ClassDumper example duplicates field attribute types</action>
       <action issue="BCEL-258" type="fix">No tests to check the output of dump methods</action>

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Select.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Select.java?rev=1698238&r1=1698237&r2=1698238&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Select.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Select.java Thu Aug 27 22:55:48 2015
@@ -89,12 +89,15 @@ public abstract class Select extends Bra
      * @param defaultTarget default instruction target
      */
     Select(short opcode, int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) {
-        super(opcode, defaultTarget);
+        // don't set default target before instuction is built
+        super(opcode, null);
+        this.match = match;
         this.targets = targets;
+        // now it's safe to set default target
+        setTarget(defaultTarget);
         for (InstructionHandle target2 : targets) {
             notifyTarget(null, target2, this);
         }
-        this.match = match;
         if ((match_length = match.length) != targets.length) {
             throw new ClassGenException("Match and target array have not the same length: Match length: " +
                 match.length + " Target length: " + targets.length);