Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1348

StackOverflowError on TypeUtils.toString(...) for a generic return type of Enum.valueOf

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.6
    • 3.7
    • lang.reflect.*
    • None
    • Java 8 update 144

    Description

      The following code

      final Method method = Enum.class.getMethod("valueOf", Class.class, String.class);
      final String typeText = TypeUtils.toString(method.getGenericReturnType());
      

      throws the following

      Exception in thread "main" java.lang.StackOverflowError
      	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.getRawType(ParameterizedTypeImpl.java:126)
      	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.getRawType(ParameterizedTypeImpl.java:40)
      	at org.apache.commons.lang3.reflect.TypeUtils.parameterizedTypeToString(TypeUtils.java:1790)
      	at org.apache.commons.lang3.reflect.TypeUtils.toString(TypeUtils.java:1666)
      	at org.apache.commons.lang3.reflect.TypeUtils.appendAllTo(TypeUtils.java:1846)
      	at org.apache.commons.lang3.reflect.TypeUtils.typeVariableToString(TypeUtils.java:1775)
      	at org.apache.commons.lang3.reflect.TypeUtils.toString(TypeUtils.java:1672)
      	at org.apache.commons.lang3.reflect.TypeUtils.appendAllTo(TypeUtils.java:1846)
      	at org.apache.commons.lang3.reflect.TypeUtils.parameterizedTypeToString(TypeUtils.java:1803)
      	at org.apache.commons.lang3.reflect.TypeUtils.toString(TypeUtils.java:1666)
      	at org.apache.commons.lang3.reflect.TypeUtils.appendAllTo(TypeUtils.java:1846)
      	at org.apache.commons.lang3.reflect.TypeUtils.typeVariableToString(TypeUtils.java:1775)
      	at org.apache.commons.lang3.reflect.TypeUtils.toString(TypeUtils.java:1672)
      	at org.apache.commons.lang3.reflect.TypeUtils.appendAllTo(TypeUtils.java:1846)
      	at org.apache.commons.lang3.reflect.TypeUtils.parameterizedTypeToString(TypeUtils.java:1803)
      	at org.apache.commons.lang3.reflect.TypeUtils.toString(TypeUtils.java:1666)
      	at org.apache.commons.lang3.reflect.TypeUtils.appendAllTo(TypeUtils.java:1846)
      	at org.apache.commons.lang3.reflect.TypeUtils.typeVariableToString(TypeUtils.java:1775)
      	at org.apache.commons.lang3.reflect.TypeUtils.toString(TypeUtils.java:1672)
      	at org.apache.commons.lang3.reflect.TypeUtils.appendAllTo(TypeUtils.java:1846)
      	at org.apache.commons.lang3.reflect.TypeUtils.parameterizedTypeToString(TypeUtils.java:1803)
      	at org.apache.commons.lang3.reflect.TypeUtils.toString(TypeUtils.java:1666)
      	at org.apache.commons.lang3.reflect.TypeUtils.appendAllTo(TypeUtils.java:1846)
      	at org.apache.commons.lang3.reflect.TypeUtils.typeVariableToString(TypeUtils.java:1775)
      	at org.apache.commons.lang3.reflect.TypeUtils.toString(TypeUtils.java:1672)
      ...
      

      Attachments

        Activity

          People

            pascalschumacher Pascal Schumacher
            dimitrovchi Dmitry Ovchinnikov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: