Skip to content

Commit

Permalink
Fix descriptor utils bug
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed May 1, 2013
1 parent 5c7a719 commit 8f4df80
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@
* Utility class for working with method descriptors
*
* @author Stuart Douglas
*
*/
public class DescriptorUtils {
/**
* Changes a class name to the internal form suitable for use in a descriptor string.
*
* <p/>
* e.g. java.lang.String => Ljava/lang/String;
*/
public static String makeDescriptor(String className) {
Expand Down Expand Up @@ -99,9 +98,9 @@ public static String[] parameterDescriptors(String methodDescriptor) {
++i;
}
if (arraystart == -1) {
type = methodDescriptor.substring(start, i);
type = methodDescriptor.substring(start, i + 1);
} else {
type = methodDescriptor.substring(arraystart, i);
type = methodDescriptor.substring(arraystart, i + 1);
}
} else {
if (arraystart == -1) {
Expand Down Expand Up @@ -151,7 +150,6 @@ public static boolean isPrimitive(String descriptor) {

/**
* returns true if the descriptor represents a long or a double
*
*/
public static boolean isWide(String descriptor) {
if (!isPrimitive(descriptor)) {
Expand All @@ -166,7 +164,6 @@ public static boolean isWide(String descriptor) {

/**
* returns true if the class represents a long or a double
*
*/
public static boolean isWide(Class<?> cls) {
return cls == double.class || cls == long.class;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.classfilewriter.test;

import org.jboss.classfilewriter.util.DescriptorUtils;
import org.junit.Assert;
import org.junit.Test;

/**
* @author Stuart Douglas
*/
public class DescriptorUtilsTestCase {

@Test
public void testDescriptorUtils() {
Assert.assertArrayEquals(new String[]{"Lorg/xnio/OptionsMap;"}, DescriptorUtils.parameterDescriptors("(Lorg/xnio/OptionsMap;)V"));
}

}

0 comments on commit 8f4df80

Please sign in to comment.