[forge-issues] [JBoss JIRA] (ROASTER-117) Cannot set supertype with nested generics
Kai Müller (Jira)
issues at jboss.org
Sat Jan 19 16:10:00 EST 2019
[ https://issues.jboss.org/browse/ROASTER-117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13684436#comment-13684436 ]
Kai Müller commented on ROASTER-117:
------------------------------------
Hi,
it seems this is an issue with your test program. You executing the split on the first generic part, which is "java.util.Map<String,SomeOtherClass>". If you then execute a split on this and try to convert it to a simple type, which is "java.util.Map<String" --> that's no valid java.
Your program can be fixed, by adding another getGenericsTypeParameter and using the new value in the for loop:
{code:java}
String type = "SomeClass<java.util.Map<String,SomeOtherClass>>";
String typeD = Types.stripGenerics(type);
String simpleTypeDName = Types.toSimpleName(typeD);
String typesGeneric = Types.getGenericsTypeParameter(type);
String typesGenericMap = Types.getGenericsTypeParameter(typesGeneric);
for (String typeP : typesGenericMap.split(","))
{
System.out.println(typeP);
Types.toSimpleName(typeP.trim());
}
{code}
Best regards,
Kai
> Cannot set supertype with nested generics
> -----------------------------------------
>
> Key: ROASTER-117
> URL: https://issues.jboss.org/browse/ROASTER-117
> Project: Roaster
> Issue Type: Bug
> Components: JDT
> Affects Versions: 2.19.4.Final
> Reporter: Stefan Brötz
> Priority: Major
>
> Calling javaClassSource.setSuperType("SomeClass<java.util.Map<String,SomeOtherClass>>") throws a java.lang.StringIndexOutOfBoundsException:
> java.lang.StringIndexOutOfBoundsException: String index out of range: -15
> at java.lang.String.substring(String.java:1967)
> at org.jboss.forge.roaster.model.util.Types.isGeneric(Types.java:317)
> at org.jboss.forge.roaster.model.util.Types.toSimpleName(Types.java:192)
> at myTest(...)
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
More information about the forge-issues
mailing list