Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-916

surefire.junit4.upgradecheck fails with ClassCastException: java.lang.Class cannot be cast to java.lang.String

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.12.4
    • Fix Version/s: 2.13
    • Component/s: Junit 4.x support
    • Labels:
      None
    • Flags:
      Patch

      Description

      I specified -Dsurefire.junit4.upgradecheck on a project which had at least one class found to be affected by the check.

      Instead of reporting the affected classes, the check fails with

      org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
      java.lang.reflect.InvocationTargetException
      	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:597)
      	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
      	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
      	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
      	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
      	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
      Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.String
      	at org.apache.maven.surefire.junit4.JUnit4Provider.upgradeCheck(JUnit4Provider.java:211)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:95)
      	... 9 more
      
      

      Attached patch fixes the problem.

      Method was private and was 'unsupported' feature meant to eventually go away so didn't file a test, but I think the code is pretty obvious.

        Attachments

          Activity

            People

            • Assignee:
              krosenvold Kristian Rosenvold
              Reporter:
              plynch Peter Lynch
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: