[forge-issues] [JBoss JIRA] (ROASTER-107) Problems with generic types in MethodSource.setReturnType

Kevin Mian Kraiker (JIRA) issues at jboss.org
Wed Jun 22 12:11:00 EDT 2016


    [ https://issues.jboss.org/browse/ROASTER-107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13255939#comment-13255939 ] 

Kevin Mian Kraiker commented on ROASTER-107:
--------------------------------------------

Windows 10 x64, JDK 1.8.0u91, Maven 3.3.3

> Problems with generic types in MethodSource.setReturnType
> ---------------------------------------------------------
>
>                 Key: ROASTER-107
>                 URL: https://issues.jboss.org/browse/ROASTER-107
>             Project: Roaster
>          Issue Type: Bug
>          Components: API, Formatter
>    Affects Versions: 2.18.7.Final
>            Reporter: Kevin Mian Kraiker
>            Assignee: George Gastaldi
>             Fix For: 2.19.0.Final
>
>
> When trying to set a method's return type, if there's a space between two generic types (for example as in TreeMap<String, Object>), an IllegalArgumentExeption gets thrown saying the identifier for the second type is invalid (because it includes the space character as part of it). If there's none, then the final formatted code has one, although the non-formatted one hasn't, which is inconsistent...
> {code:java}
> 	@Test
> 	public void throwsException() {
>         JavaClassSource classSource = Roaster.create(JavaClassSource.class);
>         MethodSource<JavaClassSource> newMethod = classSource.addMethod()
>                 .setName("tstMethod")
>                 .setPublic();
>         newMethod.setReturnType("java.util.TreeMap<java.util.String, java.util.Object>"); // Counts space as part of the second type's name
>         newMethod.setBody("return new TreeMap<String, Object>();");
>         assertTrue(newMethod.getReturnType().toString().equals("TreeMap<String, Object>")); // If the exception wasn't thrown, this should pass.
>         // Also, if there's no space - as in 'java.util.TreeMap<java.util.String,java.util.Object>', the class' formatted code has one but the above test would fail.
> 	}
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the forge-issues mailing list