commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1748444 - in /commons/proper/bcel/trunk/src: changes/changes.xml main/java/org/apache/bcel/generic/Type.java test/java/org/apache/bcel/generic/TypeTestCase.java
Date Tue, 14 Jun 2016 17:02:22 GMT
Author: sebb
Date: Tue Jun 14 17:02:22 2016
New Revision: 1748444

URL: http://svn.apache.org/viewvc?rev=1748444&view=rev
Log:
BCEL-243 Type.getType() needs to understand TypeVariableSignature(s)

Added:
    commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/TypeTestCase.java   (with
props)
Modified:
    commons/proper/bcel/trunk/src/changes/changes.xml
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/Type.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=1748444&r1=1748443&r2=1748444&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/changes/changes.xml (original)
+++ commons/proper/bcel/trunk/src/changes/changes.xml Tue Jun 14 17:02:22 2016
@@ -90,6 +90,7 @@ N.B. The Clirr report shows that there a
  External code should not have been relying on such classes to provide definitions of the
constants.
 
 ">
+      <action issue="BCEL-243" type="fix">Type.getType() needs to understand TypeVariableSignature(s)</action>
       <action issue="BCEL-272" type="add">Add constants for Java 9 class file version
53</action>
       <action issue="BCEL-271" type="fix">FCONST pattern does not include FCONST_2</action>
       <action issue="BCEL-264" type="fix">Add missing Node.accept() implementations
(ConstantMethodHandle, ConstantMethodType, ParameterAnnotationEntry)</action>

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/Type.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/Type.java?rev=1748444&r1=1748443&r2=1748444&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/Type.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/Type.java Tue Jun 14 17:02:22
2016
@@ -214,13 +214,11 @@ public abstract class Type {
             wrap(consumed_chars, _temp);
             return new ArrayType(t, dim);
         } else { // type == T_REFERENCE
-            int index = signature.indexOf(';'); // Look for closing `;'
-            if (index < 0) {
-                throw new ClassFormatException("Invalid signature: " + signature);
-            }
-            //corrected concurrent private static field acess
-            wrap(consumed_chars, index + 1); // "Lblabla;" `L' and `;' are removed
-            return ObjectType.getInstance(signature.substring(1, index).replace('/', '.'));
+            // Utility.signatureToString understands how to parse
+            // generic types.
+            String parsedSignature = Utility.signatureToString(signature, false);
+            wrap(consumed_chars, parsedSignature.length() + 2); // "Lblabla;" `L' and `;'
are removed
+            return ObjectType.getInstance(parsedSignature.replace('/', '.'));
         }
     }
 

Added: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/TypeTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/TypeTestCase.java?rev=1748444&view=auto
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/TypeTestCase.java (added)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/TypeTestCase.java Tue
Jun 14 17:02:22 2016
@@ -0,0 +1,16 @@
+package org.apache.bcel.generic;
+
+import junit.framework.TestCase;
+
+public class TypeTestCase extends TestCase {
+    public void testBCEL243() {
+        // expectedValue = "Ljava/util/Map<TX;Ljava/util/List<TY;>;>;";
+        // The line commented out above is the correct expected value; however,
+        // the constructor for ObjectType is yet another place where BCEL does
+        // not understand generics so we need to substitute the modified value below.
+        String expectedValue = "Ljava/util/Map<X, java/util/List<Y>>;";
+        String actualValue = (Type.getType("Ljava/util/Map<TX;Ljava/util/List<TY;>;>;")).getSignature();
+        assertEquals("Type.getType", expectedValue, actualValue);        
+    }
+
+}

Propchange: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/TypeTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message