commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1702349 - /commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java
Date Thu, 10 Sep 2015 23:30:34 GMT
Author: sebb
Date: Thu Sep 10 23:30:33 2015
New Revision: 1702349

URL: http://svn.apache.org/r1702349
Log:
Fix most deprecations for getClassName

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java?rev=1702349&r1=1702348&r2=1702349&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java
Thu Sep 10 23:30:33 2015
@@ -21,6 +21,7 @@ import java.util.StringTokenizer;
 
 import org.apache.commons.bcel6.Constants;
 import org.apache.commons.bcel6.classfile.Constant;
+import org.apache.commons.bcel6.classfile.ConstantCP;
 import org.apache.commons.bcel6.classfile.ConstantPool;
 
 /**
@@ -118,4 +119,23 @@ public abstract class InvokeInstruction
     public Type[] getArgumentTypes( ConstantPoolGen cpg ) {
         return Type.getArgumentTypes(getSignature(cpg));
     }
+
+    /**
+     * This overrides the deprecated version as we know here that the referenced class
+     * cannot be an array unless something has gone badly wrong.
+     * @return name of the referenced class/interface
+     * @throws IllegalArgumentException if the referenced class is an array (this should
not happen)
+     */
+    @Override
+    public String getClassName( ConstantPoolGen cpg ) {
+        ConstantPool cp = cpg.getConstantPool();
+        ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
+        String className = cp.getConstantString(cmr.getClassIndex(), Constants.CONSTANT_Class);
+        if (className.startsWith("[")) {
+            throw new IllegalArgumentException("Cannot be used on an array type");
+        }
+        return className.replace('/', '.');
+    }
+
+    
 }



Mime
View raw message