Bug 357582 - Exception in Roo project
Summary: Exception in Roo project
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 1.6.12   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-13 23:03 EDT by Andrew Eisenberg CLA
Modified: 2011-09-15 21:00 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Eisenberg CLA 2011-09-13 23:03:23 EDT
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)
Comment 1 Andrew Eisenberg CLA 2011-09-13 23:06:50 EDT
Looks like return type for the particular element was set to an invalid value.
Comment 2 Andrew Eisenberg CLA 2011-09-15 13:45:10 EDT
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.
Comment 3 Andrew Eisenberg CLA 2011-09-15 13:56:06 EDT
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>.
Comment 4 Andrew Eisenberg CLA 2011-09-15 17:50:25 EDT
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>>>"));
    }
}
Comment 5 Andrew Clement CLA 2011-09-15 21:00:39 EDT
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.