You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2019/06/22 03:25:16 UTC

[GitHub] [servicecomb-java-chassis] johnyannj opened a new issue #1242: Api use inner static class will throw javassist.NotFoundException

johnyannj opened a new issue #1242: Api use inner static class will throw javassist.NotFoundException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1242
 
 
   demo:
   ```
   @RestSchema(schemaId="demo")
   class Service
   {
       public static class Model
       {
   
       }
   
       @RequestMapping(path = "/get", method = RequestMethod.GET)
       public Model foo()
       {
           return null;
       }
   }
   ```
   
   it will take error at
   
   org.apache.servicecomb.common.javassist.CtType.<init>(CtType.java:55)
   
   ```
     public CtType(JavaType javaType) {
       if (CtTypeJavaType.class.isInstance(javaType)) {
         CtType ctType = ((CtTypeJavaType) javaType).getType();
         init(ctType.ctClass, ctType.hasGenericTypes, ctType.genericSignature);
         return;
       }
   
       ClassLoader classLoader = javaType.getRawClass().getClassLoader();
       try {
         ClassPool classPool = JavassistUtils.getOrCreateClassPool(classLoader);
         **init(classPool.get(javaType.getRawClass().getCanonicalName()), javaType.hasGenericTypes(),
             javaType.getGenericSignature()**
         );
       } catch (NotFoundException e) {
         throw new IllegalStateException(
             String.format("Failed to get CtClass for %s in classloader %s.",
                 javaType.getRawClass().getName(),
                 classLoader),
             e);
       }
   }
   
   ```
   
   javaType.getRawClass().getCanonicalName() is "com.zhaoyanblog.Service.Model"
   the classPool.get will throw javassist.NotFoundException
   the right name is "com.zhaoyanblog.Service$Model"

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services