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/10 17:43:18 UTC

svn commit: r1695119 - /commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Code.java

Author: sebb
Date: Mon Aug 10 15:43:17 2015
New Revision: 1695119

URL: http://svn.apache.org/r1695119
Log:
Don't call overrideable methods from a constructor

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Code.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Code.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Code.java?rev=1695119&r1=1695118&r2=1695119&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Code.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Code.java Mon Aug 10 15:43:17 2015
@@ -45,8 +45,8 @@ import org.apache.commons.bcel6.Constant
 public final class Code extends Attribute {
 
     private static final long serialVersionUID = -432884354459701506L;
-    private int max_stack; // Maximum size of stack used by this method
-    private int max_locals; // Number of local variables
+    private int max_stack; // Maximum size of stack used by this method  // TODO this could be made final (setter is not used)
+    private int max_locals; // Number of local variables  // TODO this could be made final (setter is not used)
     private byte[] code; // Actual byte code
     private CodeException[] exception_table; // Table of handled exceptions
     private Attribute[] attributes; // or LocalVariable
@@ -115,9 +115,10 @@ public final class Code extends Attribut
         super(Constants.ATTR_CODE, name_index, length, constant_pool);
         this.max_stack = max_stack;
         this.max_locals = max_locals;
-        setCode(code);
-        setExceptionTable(exception_table);
-        setAttributes(attributes); // Overwrites length!
+        this.code = code != null ? code : new byte[0];
+        this.exception_table = exception_table != null ? exception_table : new CodeException[0];
+        this.attributes = attributes != null ? attributes : new Attribute[0];
+        super.setLength(calculateLength()); // Adjust length
     }