diff --git a/pmd/regress/test/net/sourceforge/pmd/TypeSetTest.java b/pmd/regress/test/net/sourceforge/pmd/TypeSetTest.java index 63ca8cc7bf..7f587e74a6 100644 --- a/pmd/regress/test/net/sourceforge/pmd/TypeSetTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/TypeSetTest.java @@ -61,6 +61,13 @@ public class TypeSetTest extends TestCase { public void testPrimitiveTypeResolver() throws Throwable { TypeSet.Resolver r = new TypeSet.PrimitiveTypeResolver(); assertEquals(int.class, r.resolve("int")); + assertEquals(byte.class, r.resolve("byte")); + assertEquals(long.class, r.resolve("long")); + } + + public void testVoidTypeResolver() throws Throwable { + TypeSet.Resolver r = new TypeSet.VoidResolver(); + assertEquals(void.class, r.resolve("void")); } public void testExplicitImportResolver() throws Throwable { Set imports = new HashSet(); diff --git a/pmd/src/net/sourceforge/pmd/TypeSet.java b/pmd/src/net/sourceforge/pmd/TypeSet.java index 0c8f073db9..f6b87195e4 100644 --- a/pmd/src/net/sourceforge/pmd/TypeSet.java +++ b/pmd/src/net/sourceforge/pmd/TypeSet.java @@ -93,7 +93,16 @@ public class TypeSet { } } - private String pkg; + public static class VoidResolver implements Resolver { + public Class resolve(String name) throws ClassNotFoundException { + if (name.equals("void")) { + return void.class; + } + throw new ClassNotFoundException(); + } + } + + private String pkg; private Set imports = new HashSet(); private List resolvers = new ArrayList(); @@ -129,6 +138,8 @@ public class TypeSet { } private void buildResolvers() { + resolvers.add(new PrimitiveTypeResolver()); + resolvers.add(new VoidResolver()); resolvers.add(new ExplicitImportResolver(imports)); resolvers.add(new CurrentPackageResolver(pkg)); resolvers.add(new ImplicitImportResolver());