Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] aspectj 1.8.[4, 9] - java.lang.IllegalStateException: Expecting raw type, not ...

Hi Andy,

I recreated the class hierarchy in weaver5's test tree. I have a simple test which is trying to resolve the class using ReflectionWorld. I always see a typeKind of RAW and never simple.

I even went to the trouble of naming every class and package exactly as what is in the running program. Unfortunately, capturing what is going on in the program is difficult due to the amount of initialization that occurs just before the fatal exception. I'll try a conditional breakpoint and see if I can get that working.



Stephen

On Mon, Apr 18, 2016 at 5:41 PM, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
Hey Stephen,

If you can share a program with me that fails I’m happy to dive into it, rather than you having to dive into working how to build a test. I was crafting tests in ReflectionWorldTest in weaver5 but nothing basic was triggering the issue, possibly because of something that happens earlier that I don’t know about. 

If you want to debug further yourself, stick a breakpoint in TypeMap.put() and look at what is happening when it puts the SIMPLE form of AbstractClass in there. Why did it build the SIMPLE form and not the raw or generic.

But as I say, I’m happy to look, but I just can’t recreate the problem.

cheers,
Andy

On Apr 18, 2016, at 11:16 AM, Stephen Evanchik <evanchsa@xxxxxxxxx> wrote:

Hi Andy,

I have the AspectJ source tree pulled down and will look in to generating a test. Any pointers would be appreciated; it looks I need to modify something in weaver5's test area, is that right?

            ResolvedType baseType = fromType(pt.getRawType());

This returns Class<?> of AbstractClass (so no generics as far as I can tell). However, in TypeFactory:

                if (!aBaseType.isRawType()) {


returns false because the typeKind == SIMPLE.

I think that's the bug, why it is that value is beyond me.

Stephen



On Fri, Apr 15, 2016 at 7:49 PM, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
My immediate reaction is that:

ResolvedType baseType = fromType(pt.getRawType());

might be returning the generic type and not a raw type. But I’ve been trying to craft a test case based on your declarations and nothing is failing. Do you have a test case you can share that actually fails?

I recently ran in to a problem with Spring AOP and AspectJ which appeared on this mailing list in March.

I found that thread and it didn’t really come to a satisfying conclusion, so it would be good to get this sorted.

cheers,
Andy

On Apr 14, 2016, at 8:22 AM, Stephen Evanchik <evanchsa@xxxxxxxxx> wrote:

Hello,

I recently ran in to a problem with Spring AOP and AspectJ which appeared on this mailing list in March. I'm not sure what is going on because I've changed very little that would obviously cause this exception. There are many Generic types in the project that could/would be processed by AspectJ why this one is throwing things off is a mystery. I believe the reason this type is causing a problem now is because the concrete class used to be hidden behind a JDK Proxy so the AspectJ type evaluation did not see the concrete class and it's generic type. The class signature in question looks like this:

public class ConcreteClass extends AbstractClass<ConcreteType>

where AbstractClass<T> is defined as:

public abstract AbstractClass<T> extends AbstractSuperClass <T, ID> implements InterfaceOne InterfaceTwo<T>


Here's the stack trace:

Caused by: java.lang.IllegalStateException: Expecting raw type, not: ConcreteClass
    at org.aspectj.weaver.TypeFactory.createParameterizedType(TypeFactory.java:34)
    at org.aspectj.weaver.reflect.JavaLangTypeToResolvedTypeConverter.fromType(JavaLangTypeToResolvedTypeConverter.java:79)
    at org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.getSuperclass(Java15ReflectionBasedReferenceTypeDelegate.java:156)
    at org.aspectj.weaver.ReferenceType.getSuperclass(ReferenceType.java:987)
    at org.aspectj.weaver.JoinPointSignatureIterator.addSignaturesUpToFirstDefiningMember(JoinPointSignatureIterator.java:95)
    at org.aspectj.weaver.JoinPointSignatureIterator.<init>(JoinPointSignatureIterator.java:49)
    at org.aspectj.weaver.MemberImpl.getJoinPointSignatures(MemberImpl.java:515)
    at org.aspectj.weaver.patterns.SignaturePattern.matches(SignaturePattern.java:316)
    at org.aspectj.weaver.patterns.KindedPointcut.matchInternal(KindedPointcut.java:197)
    at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137)
    at org.aspectj.weaver.patterns.OrPointcut.matchInternal(OrPointcut.java:56)
    at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137)
    at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.getShadowMatch(PointcutExpressionImpl.java:319)
    at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesExecution(PointcutExpressionImpl.java:129)
    at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesMethodExecution(PointcutExpressionImpl.java:110)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.getShadowMatch(AspectJExpressionPointcut.java:408)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:266)
    at org.springframework.aop.support.MethodMatchers.matches(MethodMatchers.java:92)
    at org.springframework.aop.support.MethodMatchers$IntersectionMethodMatcher.matches(MethodMatchers.java:228)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:223)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:262)
    at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:294)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:118)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:88)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:69)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:361)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:324)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:409)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.postProcessObjectFromFactoryBean(AbstractAutowireCapableBeanFactory.java:1657)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:129)


I'm confused about this code in JavaLangTypeToResolvedTypeContainer.fromType():

...
        } else if (aType instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType) aType;
            ResolvedType baseType = fromType(pt.getRawType());
            Type[] args = pt.getActualTypeArguments();
            ResolvedType[] resolvedArgs = fromTypes(args);
            /*
             * StringBuilder sb = new StringBuilder(); for (int i = 0; i < resolvedArgs.length; i++) {
             * sb.append(resolvedArgs[i]).append(" "); } for (int i = 0; i < resolvedArgs.length; i++) { if (resolvedArgs[i] ==
             * null) { String ss = ""; try { ss = aType.toString(); } catch (Exception e) { } throw new
             * IllegalStateException("Parameterized type problem.  basetype=" + baseType + " arguments=" + sb.toString() + " ss=" +
             * ss); } }
             */
            return TypeFactory.createParameterizedType(baseType, resolvedArgs, getWorld());

..

and then TypeFactory.createParameterizedType(...):

        ResolvedType baseType = aBaseType;
        if (!aBaseType.isGenericType()) {
            // try and find the generic type...
            if (someTypeParameters != null && someTypeParameters.length > 0) {
                if (!aBaseType.isRawType()) {
                    throw new IllegalStateException("Expecting raw type, not: " + aBaseType);
                }
                baseType = baseType.getGenericType();
                if (baseType == null) {
                    throw new IllegalStateException("Raw type does not have generic type set");
                }
            } // else if someTypeParameters is null, then the base type is allowed to be non-generic, it's an inner
        }



because I don't understand why:

               if (!aBaseType.isRawType()) {
                    throw new IllegalStateException("Expecting raw type, not: " + aBaseType);
                }

aBaseType, which is a RawType from above, is evaluating to anything other than a raw type.


Stephen
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-dev


_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-dev



--
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-dev


_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-dev



--

Back to the top