Spring Roo
  1. Spring Roo
  2. ROO-1529

parameterTypes collection from MethodMetada is not well formed

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1.0.M1
    • Fix Version/s: 1.1.0.RC1
    • Component/s: @ CORE
    • Labels:
      None
    • Environment:
      SUN JDK 1.5.0_07
      Ubuntu 10.04
      Eclipse 3.5.1

      Description

      Hi! I'm trying to inspect Parameter Types defined in an especific method.
      When I use:

      OperationServiceImpl.java
      ClassOrInterfaceTypeDetails tmpClassDetails = classpathOperations
      	.getClassOrInterface(javaType);
      
      MutableClassOrInterfaceTypeDetails classDetails = (MutableClassOrInterfaceTypeDetails) tmpClassDetails;
      
      List<? extends MethodMetadata> methodList = classDetails
      .getDeclaredMethods();
      

      To analyze parameter types from a method in a class:

      org.test.service.layer.project.services.TestService.java
      public String correctInputParameters(Car listaVacia,
              java.util.List<String> listaLlena, HashSet<String> primerHashSet,
              Set<String> set,
              String name)
              throws Exception, NullPointerException {
          return "aaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaah";
      }
      

      Content of MethodMetadata.toString():

       
      [JavaParserMethodMetadata@232b2a18 declaredByMetadataId = [null], modifier = 'public', methodName = correctInputParameters, parameterTypes = list[org.gvnix.test.service.layer.project.domain.Car, java.util.List<java.lang.String>, org.test.service.layer.project.services.HashSet<java.lang.String>, org.test.service.layer.project.services.Set<java.lang.String>, java.lang.String], parameterNames = list[listaVacia, listaLlena, primerHashSet, set, name], returnType = java.lang.String, throwsTypes = list[java.lang.Exception, java.lang.NullPointerException], annotations = list[[JavaParserAnnotationMetadata@17dc5237 annotationType = org.gvnix.service.layer.roo.addon.annotations.GvNIXWebMethod, attributes = list[operationName -> correctInputParameters, requestWrapperName -> correctInputParameters, requestWrapperNamespace -> http://services.project.layer.service.test.gvnix.org/, requestWrapperClassName -> org.gvnix.test.service.layer.project.services.IncorrectInputParametersRequestWrapper, responseWrapperName -> correctInputParametersResponse, responseWrapperNamespace -> http://services.project.layer.service.test.gvnix.org/, responseWrapperClassName -> org.gvnix.test.service.layer.project.services.IncorrectInputParametersResponse, resultName -> return, resultNamespace -> http://services.project.layer.service.test.gvnix.org/, webResultType -> java.lang.String]]], body = '{
          return "Message returned.";
      }']
      

      Parameter types that are not fullyqualyfied in method like HashSet<String> are loaded with TestService package name as:

       
      org.test.service.layer.project.services.HashSet<java.lang.String> 
      

      instead of:

       
      java.util.HashSet<java.lang.String>
      

      The collections as parameterTypes are not well formed with the complete JavaPath (java package + java class name).

      This problem is like I posted in JIRA with throw types:

      Thank you !

        Issue Links

          Activity

          Hide
          Alan Stewart added a comment -

          Is this still an issue? I can't reproduce it. I created a method,
          public String correctInputParameters(Entityz z, java.util.List<String> bars, HashSet<String> foos) throws Exception, NullPointerException

          { return "alan"; }

          and got
          ~.domain.Entityx roo> test method --javaType ~.domain.Entityx
          [[JavaParserMethodMetadata@6491cf0b declaredByMetadataId = [null], modifier = 'public', methodName = correctInputParameters, parameterTypes = list[com.foo.roo1409.domain.Entityz, java.util.List<java.lang.String>, java.util.HashSet<java.lang.String>], parameterNames = list[z, bars, foos], returnType = java.lang.String, throwsTypes = list[java.lang.Exception, java.lang.NullPointerException], annotations = list[[empty]], customData = {}, body = '{
          return "alan";

          The HashSet was fully qualified

          Show
          Alan Stewart added a comment - Is this still an issue? I can't reproduce it. I created a method, public String correctInputParameters(Entityz z, java.util.List<String> bars, HashSet<String> foos) throws Exception, NullPointerException { return "alan"; } and got ~.domain.Entityx roo> test method --javaType ~.domain.Entityx [[JavaParserMethodMetadata@6491cf0b declaredByMetadataId = [null] , modifier = 'public', methodName = correctInputParameters, parameterTypes = list [com.foo.roo1409.domain.Entityz, java.util.List<java.lang.String>, java.util.HashSet<java.lang.String>] , parameterNames = list [z, bars, foos] , returnType = java.lang.String, throwsTypes = list [java.lang.Exception, java.lang.NullPointerException] , annotations = list[ [empty] ], customData = {}, body = '{ return "alan"; The HashSet was fully qualified
          Hide
          Alan Stewart added a comment -

          Can't reproduce this for now. I need to close it as we are doing a release. Please ask for it to be re-opened if you still find the issue

          Show
          Alan Stewart added a comment - Can't reproduce this for now. I need to close it as we are doing a release. Please ask for it to be re-opened if you still find the issue
          Hide
          Ricardo García added a comment -

          Sorry for been so late, but I haven't got enought time.

          Here is an example to reprode the error with test Add-on to get toString representation of class methods:

          Method testMethod:

          @GvNIXWebMethod(operationName = "testMethod", resultName = "void", webResultType = Void.class)
          public void testMethod() {
              return;
          }
          

          Method testMethod toString:

          [JavaParserMethodMetadata@6f48db9c declaredByMetadataId = [null], modifier = 'public', methodName = dajkjdsaj, parameterTypes = list[[empty]], parameterNames = list[[empty]], returnType = void, throwsTypes = list[[empty]], annotations = list[[JavaParserAnnotationMetadata@184a17d8 annotationType = org.gvnix.service.layer.roo.addon.annotations.GvNIXWebMethod, attributes = list[operationName -> dajkjdsaj, resultName -> void, webResultType -> java.lang.Void]]], body = '{
              return;
          

          Method correctInputParameters:

          public String correctInputParameters(Car listaVacia,
                  java.util.List<String> listaLlena, HashSet<String> primerHashSet,
                  Set<String> set, String name) throws Exception,
                  NullPointerException {
          
              return "aaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaah";
          }
          

          Method correctInputParameters toString:

          [JavaParserMethodMetadata@5e8fee26 declaredByMetadataId = [null], modifier = 'public', methodName = correctInputParameters, parameterTypes = list[org.gvnix.test.relation.list.table.service.Car, java.util.List<java.lang.String>, java.util.HashSet<java.lang.String>, org.gvnix.test.relation.list.table.service.Set<java.lang.String>, java.lang.String], parameterNames = list[listaVacia, listaLlena, primerHashSet, set, name], returnType = java.lang.String, throwsTypes = list[java.lang.Exception, java.lang.NullPointerException], annotations = list[[empty]], body = '{
              return "aaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaah";
          }']
          

          Method testMethod returnNothing:Parsing the method:

          @GvNIXWebMethod(operationName = "returnNada", requestWrapperName = "returnNada", requestWrapperNamespace = "http://service.table.list.relation.test.gvnix.org/", requestWrapperClassName = "org.gvnix.test.relation.list.table.service.ReturnNadaRequestWrapper", resultName = "return", resultNamespace = "http://service.table.list.relation.test.gvnix.org/", webResultType = String.class, responseWrapperName = "returnNadaResponse", responseWrapperNamespace = "http://service.table.list.relation.test.gvnix.org/", responseWrapperClassName = "org.gvnix.test.relation.list.table.service.ReturnNadaResponse")
          public String returnNothing(
                  @WebParam(name = "nenene", partName = "parameters", mode = Mode.IN, header = false)
                  String nenene, 
                  @WebParam(name = "numerooo", partName = "parameters", mode = Mode.IN, header = false)
                  Integer numerooo, 
                  @WebParam(name = "cuatrooo", targetNamespace = "http://service.table.list.relation.test.gvnix.org/", partName = "parameters", mode = Mode.IN, header = false)
                  Cuarto cuatrooo, 
                  @WebParam(name = "setString", partName = "parameters", mode = Mode.IN, header = false) 
                  Set<String> set,
                  @WebParam(name = "hashSetString", partName = "parameters", mode = Mode.IN, header = false) 
                  HashSet<String> hashSetString) throws Exception {
              return "mensajeeeeeeeeeeeeeeeEE";
          }
          

          Method returnNothing toString:

          com.sun.jdi.InvocationException occurred invoking method.
          
          java.lang.NullPointerException
              at org.springframework.roo.classpath.details.AnnotationMetadataUtils.computeAttributeValue(AnnotationMetadataUtils.java:117)
              at org.springframework.roo.classpath.details.AnnotationMetadataUtils.toSourceForm(AnnotationMetadataUtils.java:78)
              at org.springframework.roo.classpath.details.AnnotationMetadataUtils.toSourceForm(AnnotationMetadataUtils.java:36)
              at org.springframework.roo.classpath.details.annotations.AnnotatedJavaType.toString(AnnotatedJavaType.java:52)
              at java.lang.String.valueOf(String.java:2615)
              at org.springframework.roo.support.style.DefaultValueStyler.style(DefaultValueStyler.java:78)
              at org.springframework.roo.support.style.DefaultValueStyler.style(DefaultValueStyler.java:107)
              at org.springframework.roo.support.style.DefaultValueStyler.style(DefaultValueStyler.java:72)
              at org.springframework.roo.support.style.DefaultToStringStyler.styleValue(DefaultToStringStyler.java:91)
              at org.springframework.roo.support.style.DefaultToStringStyler.styleField(DefaultToStringStyler.java:79)
              at org.springframework.roo.support.style.ToStringCreator.append(ToStringCreator.java:156)
              at org.springframework.roo.classpath.javaparser.details.JavaParserMethodMetadata.toString(JavaParserMethodMetadata.java:164)
              at org.test.service.layer.roo.addon.OperationsImpl.getMethodFromClass(OperationsImpl.java:195)
              at org.test.service.layer.roo.addon.Commands.getMethodFromClass(Commands.java:62)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.springframework.roo.support.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:191)
              at org.springframework.roo.process.manager.ProcessManagerHostedExecutionStrategy$1.callback(ProcessManagerHostedExecutionStrategy.java:34)
              at org.springframework.roo.process.manager.internal.DefaultProcessManager.doTransactionally(DefaultProcessManager.java:169)
              at org.springframework.roo.process.manager.internal.DefaultProcessManager.execute(DefaultProcessManager.java:132)
              at org.springframework.roo.process.manager.ProcessManagerHostedExecutionStrategy.execute(ProcessManagerHostedExecutionStrategy.java:32)
              at org.springframework.roo.shell.AbstractShell.executeCommand(AbstractShell.java:158)
              at org.springframework.roo.shell.jline.JLineShell.promptLoop(JLineShell.java:200)
              at org.springframework.roo.shell.jline.JLineShell.run(JLineShell.java:126)
              at java.lang.Thread.run(Thread.java:595)
          

          Error in parameterTypes value:

          com.sun.jdi.InvocationException occurred invoking method.
          

          when in JavaParserMethodMetadata access to toString() method:

          tsc.append("parameterTypes", parameterTypes);
          

          The Error is reproduced when the method has annotations assigned to Method parameter types.
          You can try it using this test Add-on attached to issue with the command ``get toString methods`` with the parameter --class to inspect a selected class with the methods defined in the issue.

          Thank you!

          Show
          Ricardo García added a comment - Sorry for been so late, but I haven't got enought time. Here is an example to reprode the error with test Add-on to get toString representation of class methods: Method testMethod: @GvNIXWebMethod(operationName = "testMethod" , resultName = "void" , webResultType = Void .class) public void testMethod() { return ; } Method testMethod toString : [JavaParserMethodMetadata@6f48db9c declaredByMetadataId = [null], modifier = 'public', methodName = dajkjdsaj, parameterTypes = list[[empty]], parameterNames = list[[empty]], returnType = void, throwsTypes = list[[empty]], annotations = list[[JavaParserAnnotationMetadata@184a17d8 annotationType = org.gvnix.service.layer.roo.addon.annotations.GvNIXWebMethod, attributes = list[operationName -> dajkjdsaj, resultName -> void, webResultType -> java.lang.Void]]], body = '{ return; Method correctInputParameters: public String correctInputParameters(Car listaVacia, java.util.List< String > listaLlena, HashSet< String > primerHashSet, Set< String > set, String name) throws Exception, NullPointerException { return "aaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaah" ; } Method correctInputParameters toString : [JavaParserMethodMetadata@5e8fee26 declaredByMetadataId = [null], modifier = 'public', methodName = correctInputParameters, parameterTypes = list[org.gvnix.test.relation.list.table.service.Car, java.util.List<java.lang.String>, java.util.HashSet<java.lang.String>, org.gvnix.test.relation.list.table.service.Set<java.lang.String>, java.lang.String], parameterNames = list[listaVacia, listaLlena, primerHashSet, set, name], returnType = java.lang.String, throwsTypes = list[java.lang.Exception, java.lang.NullPointerException], annotations = list[[empty]], body = '{ return "aaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaah"; }'] Method testMethod returnNothing :Parsing the method: @GvNIXWebMethod(operationName = "returnNada" , requestWrapperName = "returnNada" , requestWrapperNamespace = "http: //service.table.list.relation.test.gvnix.org/" , requestWrapperClassName = "org.gvnix.test.relation.list.table.service.ReturnNadaRequestWrapper" , resultName = " return " , resultNamespace = "http://service.table.list.relation.test.gvnix.org/" , webResultType = String .class, responseWrapperName = "returnNadaResponse" , responseWrapperNamespace = "http://service.table.list.relation.test.gvnix.org/" , responseWrapperClassName = "org.gvnix.test.relation.list.table.service.ReturnNadaResponse" ) public String returnNothing( @WebParam(name = "nenene" , partName = "parameters" , mode = Mode.IN, header = false ) String nenene, @WebParam(name = "numerooo" , partName = "parameters" , mode = Mode.IN, header = false ) Integer numerooo, @WebParam(name = "cuatrooo" , targetNamespace = "http: //service.table.list.relation.test.gvnix.org/" , partName = "parameters" , mode = Mode.IN, header = false ) Cuarto cuatrooo, @WebParam(name = "setString" , partName = "parameters" , mode = Mode.IN, header = false ) Set< String > set, @WebParam(name = "hashSetString" , partName = "parameters" , mode = Mode.IN, header = false ) HashSet< String > hashSetString) throws Exception { return "mensajeeeeeeeeeeeeeeeEE" ; } Method returnNothing toString : com.sun.jdi.InvocationException occurred invoking method. java.lang.NullPointerException at org.springframework.roo.classpath.details.AnnotationMetadataUtils.computeAttributeValue(AnnotationMetadataUtils.java:117) at org.springframework.roo.classpath.details.AnnotationMetadataUtils.toSourceForm(AnnotationMetadataUtils.java:78) at org.springframework.roo.classpath.details.AnnotationMetadataUtils.toSourceForm(AnnotationMetadataUtils.java:36) at org.springframework.roo.classpath.details.annotations.AnnotatedJavaType.toString(AnnotatedJavaType.java:52) at java.lang.String.valueOf(String.java:2615) at org.springframework.roo.support.style.DefaultValueStyler.style(DefaultValueStyler.java:78) at org.springframework.roo.support.style.DefaultValueStyler.style(DefaultValueStyler.java:107) at org.springframework.roo.support.style.DefaultValueStyler.style(DefaultValueStyler.java:72) at org.springframework.roo.support.style.DefaultToStringStyler.styleValue(DefaultToStringStyler.java:91) at org.springframework.roo.support.style.DefaultToStringStyler.styleField(DefaultToStringStyler.java:79) at org.springframework.roo.support.style.ToStringCreator.append(ToStringCreator.java:156) at org.springframework.roo.classpath.javaparser.details.JavaParserMethodMetadata.toString(JavaParserMethodMetadata.java:164) at org.test.service.layer.roo.addon.OperationsImpl.getMethodFromClass(OperationsImpl.java:195) at org.test.service.layer.roo.addon.Commands.getMethodFromClass(Commands.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.roo.support.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:191) at org.springframework.roo.process.manager.ProcessManagerHostedExecutionStrategy$1.callback(ProcessManagerHostedExecutionStrategy.java:34) at org.springframework.roo.process.manager.internal.DefaultProcessManager.doTransactionally(DefaultProcessManager.java:169) at org.springframework.roo.process.manager.internal.DefaultProcessManager.execute(DefaultProcessManager.java:132) at org.springframework.roo.process.manager.ProcessManagerHostedExecutionStrategy.execute(ProcessManagerHostedExecutionStrategy.java:32) at org.springframework.roo.shell.AbstractShell.executeCommand(AbstractShell.java:158) at org.springframework.roo.shell.jline.JLineShell.promptLoop(JLineShell.java:200) at org.springframework.roo.shell.jline.JLineShell.run(JLineShell.java:126) at java.lang.Thread.run(Thread.java:595) Error in parameterTypes value: com.sun.jdi.InvocationException occurred invoking method. when in JavaParserMethodMetadata access to toString() method: tsc.append( "parameterTypes" , parameterTypes); The Error is reproduced when the method has annotations assigned to Method parameter types. You can try it using this test Add-on attached to issue with the command ``get toString methods`` with the parameter --class to inspect a selected class with the methods defined in the issue. Thank you!

            People

            • Assignee:
              Alan Stewart
              Reporter:
              Ricardo García
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: