Community
Participate
Working Groups
Here is an exception that was found in an error log coming from the Roo pet clinic project. Is there anything we can do about this? java.lang.IllegalArgumentException: Vet> at org.eclipse.jdt.core.Signature.createCharArrayTypeSignature(Signature.java:634) at org.eclipse.jdt.core.Signature.createTypeSignature(Signature.java:606) at org.eclipse.ajdt.core.javaelements.AspectJMemberElement.getSignature(AspectJMemberElement.java:202) at org.springframework.ide.eclipse.core.java.Introspector.getAllMethods(Introspector.java:359) at org.springframework.ide.eclipse.core.java.annotation.JdtBasedAnnotationMetadata.init(JdtBasedAnnotationMetadata.java:70) at org.springframework.ide.eclipse.core.java.annotation.JdtBasedAnnotationMetadata.<init>(JdtBasedAnnotationMetadata.java:50) at org.springframework.ide.eclipse.beans.core.metadata.model.AbstractAnnotationReadingMetadataProvider.getAnnotationMetadata(AbstractAnnotationReadingMetadataProvider.java:103) at org.springframework.ide.eclipse.beans.core.metadata.model.AbstractAnnotationReadingMetadataProvider.provideBeanMetadata(AbstractAnnotationReadingMetadataProvider.java:69) at org.springframework.ide.eclipse.beans.core.metadata.internal.model.BeanMetadataBuilderJob$1.run(BeanMetadataBuilderJob.java:198) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.springframework.ide.eclipse.beans.core.metadata.internal.model.BeanMetadataBuilderJob.attachMetadataToBean(BeanMetadataBuilderJob.java:191) at org.springframework.ide.eclipse.beans.core.metadata.internal.model.BeanMetadataBuilderJob.attachMetadata(BeanMetadataBuilderJob.java:170) at org.springframework.ide.eclipse.beans.core.metadata.internal.model.BeanMetadataBuilderJob.run(BeanMetadataBuilderJob.java:141) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Looks like return type for the particular element was set to an invalid value.
The problem here is happening because IProgramElement.getCorrespondingType(false) is not returning the proper non-qualified type name. I'll look deeper into this and find out exactly what it should be returning and how to make the change so that it does return the correct value.
In this particular case, IProgramElement.getCorrespondingType(true) will correctly return: java.util.List<com.springsource.petclinic.domain.Vet> However, the logic for getCorrespondingType just looks for the last '.' and removes everything before that to create the simple name, which is wrong when generics are involved. The particular exception being found here occurs because IntertypeElement.getSignature() creates an unresolved type signature (ie- using simple names and beginning with 'Q'). The reason why we need to use an unresolved signature is that the signature generated must accurately reflect the source code (ie- if the source code uses simple names, then the signature must be unresolved). So, we must fix IProgramElement.getCorrespondingType(false). It must return: List<Vet>.
Here is a simple method with some test cases that should be useful for solving the problem. It can be used in ProgramElement.getCorrespondingType(). import junit.framework.TestCase; public class Converter extends TestCase { String convert(String qualName) { char[] charArray = qualName.toCharArray(); StringBuilder candidate = new StringBuilder(charArray.length); StringBuilder complete = new StringBuilder(charArray.length); for (char c : charArray) { switch (c) { case '.': candidate.delete(0, candidate.length()); break; case '<': case ',': case '>': complete.append(candidate).append(c); candidate.delete(0, candidate.length()); break; default: candidate.append(c); } } complete.append(candidate); return complete.toString(); } public void testConvert1() throws Exception { assertEquals("AAA", convert("AAA")); } public void testConvert2() throws Exception { assertEquals("AAA", convert("a.b.c.AAA")); } public void testConvert2a() throws Exception { assertEquals("A", convert("aa.ba.ca.A")); } public void testConvert3() throws Exception { assertEquals("AAA<>", convert("a.b.c.AAA<>")); } public void testConvert4() throws Exception { assertEquals("AAA<A>", convert("a.b.c.AAA<A>")); } public void testConvert5() throws Exception { assertEquals("AAA<A>", convert("a.b.c.AAA<aa.A>")); } public void testConvert6() throws Exception { assertEquals("AAA<A,B>", convert("a.b.c.AAA<aa.A,bb.B>")); } public void testConvert7() throws Exception { assertEquals("AAA<A<B>>", convert("a.b.c.AAA<aa.A<bb.B>>")); } public void testConvert8() throws Exception { assertEquals("AAA<A<B>,AA<GG<KK>>>", convert("a.b.c.AAA<aa.A<bb.B>,a.b.c.AA<GG<KK>>>")); } }
fix is in. I'll put an AspectJ into AJDT imminently to ensure we can get the fix into AJDT for STS 2.8.0.M2.