commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1752106 - in /commons/proper/bcel/trunk: ./ src/changes/ src/main/java/org/apache/bcel/generic/ src/test/java/org/apache/bcel/ src/test/java/org/apache/bcel/data/
Date Sun, 10 Jul 2016 20:02:39 GMT
Author: britter
Date: Sun Jul 10 20:02:39 2016
New Revision: 1752106

URL: http://svn.apache.org/viewvc?rev=1752106&view=rev
Log:
BCEL-262: InvokeInstruction.getClassName(ConstantPoolGen) should not throw an exception when
it detects an array. Thanks to Mark Roberts.

Added:
    commons/proper/bcel/trunk/src/test/java/org/apache/bcel/data/PLSETestEnum.java
Modified:
    commons/proper/bcel/trunk/RELEASE-NOTES.txt
    commons/proper/bcel/trunk/src/changes/changes.xml
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InvokeInstruction.java
    commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PLSETestCase.java

Modified: commons/proper/bcel/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/RELEASE-NOTES.txt?rev=1752106&r1=1752105&r2=1752106&view=diff
==============================================================================
--- commons/proper/bcel/trunk/RELEASE-NOTES.txt [utf-8] (original)
+++ commons/proper/bcel/trunk/RELEASE-NOTES.txt [utf-8] Sun Jul 10 20:02:39 2016
@@ -190,8 +190,8 @@ o BCEL-177: When reading the number of p
 CHANGES:
 ========
 
-o BCEL-262: InvokeInstruction.getClassName(ConstantPoolGen) should throw an
-            exception when it detects an array. Thanks to Mark Roberts.
+o BCEL-262: InvokeInstruction.getClassName(ConstantPoolGen) should not throw 
+            an exception when it detects an array. Thanks to Mark Roberts.
 o BCEL-230: Document the Java platform requirement clearly and early.
 o BCEL-211: Some additional clone methods should be public.
 o BCEL-127: Document that Instruction Factory returns singleton instances.

Modified: commons/proper/bcel/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/changes/changes.xml?rev=1752106&r1=1752105&r2=1752106&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/changes/changes.xml [utf-8] (original)
+++ commons/proper/bcel/trunk/src/changes/changes.xml [utf-8] Sun Jul 10 20:02:39 2016
@@ -108,7 +108,7 @@ For full information about API changes p
 
     http://commons.apache.org/bcel/clirr-report.html">
       <action issue="BCEL-262" type="update" dev="britter" due-to="Mark Roberts">InvokeInstruction.getClassName(ConstantPoolGen)

-                                          should throw an exception when it detects an array.</action>
+                                          should not throw an exception when it detects an
array.</action>
       <action issue="BCEL-237" type="fix" dev="sebb">non-empty final arrays should
be private as they are mutable.</action>
       <action issue="BCEL-230" type="update" dev="britter">Document the Java platform
requirement clearly and early.</action>
       <action issue="BCEL-243" type="fix">Type.getType() needs to understand TypeVariableSignature(s).</action>

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InvokeInstruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InvokeInstruction.java?rev=1752106&r1=1752105&r2=1752106&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InvokeInstruction.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InvokeInstruction.java
Sun Jul 10 20:02:39 2016
@@ -93,9 +93,8 @@ public abstract class InvokeInstruction
 
     /**
      * This overrides the deprecated version as we know here that the referenced class
-     * cannot be an array unless something has gone badly wrong.
      * may legally be an array.
-     * *
+     *
      * @return name of the referenced class/interface
      * @throws IllegalArgumentException if the referenced class is an array (this should
not happen)
      */ 
@@ -104,9 +103,6 @@ public abstract class InvokeInstruction
         final ConstantPool cp = cpg.getConstantPool();
         final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
         final String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class);
-        if (className.startsWith("[")) {
-            throw new IllegalArgumentException("Cannot be used on an array type");
-        }
         return className.replace('/', '.');
     }
 

Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PLSETestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PLSETestCase.java?rev=1752106&r1=1752105&r2=1752106&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PLSETestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PLSETestCase.java Sun Jul 10 20:02:39
2016
@@ -23,6 +23,9 @@ import org.apache.bcel.classfile.LocalVa
 import org.apache.bcel.classfile.Method;
 import org.apache.bcel.generic.ClassGen;
 import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.InstructionHandle;
+import org.apache.bcel.generic.InstructionList;
+import org.apache.bcel.generic.InvokeInstruction;
 import org.apache.bcel.generic.MethodGen;
 import org.apache.bcel.generic.Type;
 
@@ -62,4 +65,25 @@ public class PLSETestCase extends Abstra
         //System.out.println(new_lvt);
         assertEquals("number of locals", lvt.getTableLength(), new_lvt.getTableLength());
     }
+
+    /**
+     * BCEL-262: 
+     */
+    public void testB262() throws ClassNotFoundException
+    {
+        final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.PLSETestEnum");
+        final ClassGen gen = new ClassGen(clazz);
+        final ConstantPoolGen pool = gen.getConstantPool();
+        // get the values() method
+        final Method m = gen.getMethodAt(0);
+        final MethodGen mg = new MethodGen(m, gen.getClassName(), pool);
+        final InstructionList il = mg.getInstructionList();
+        // get the invokevirtual instruction
+        final InstructionHandle ih = il.findHandle(3);
+        final InvokeInstruction ii = (InvokeInstruction)(ih.getInstruction());
+        // without fix, the getClassName() will throw:
+        //   java.lang.IllegalArgumentException: Cannot be used on an array type
+        final String cn = ii.getClassName(pool);
+        assertEquals("[Lorg.apache.bcel.data.PLSETestEnum;", cn);
+    }
 }

Added: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/data/PLSETestEnum.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/data/PLSETestEnum.java?rev=1752106&view=auto
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/data/PLSETestEnum.java (added)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/data/PLSETestEnum.java Sun Jul
10 20:02:39 2016
@@ -0,0 +1,5 @@
+package org.apache.bcel.data;
+
+public enum PLSETestEnum {
+    TEST_VALUE;
+}



Mime
View raw message