Uploaded image for project: 'EasyAnt'
  1. EasyAnt
  2. EASYANT-75

Class.getMethod / Class.invoke: compliance with J2SE 1.7

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 0.9, 0.10
    • 0.10
    • Core

    Description

      When running EasyAnt with J2SE 1.7, calling EasyAntEngine.guessEasyantCoreJarUrl() raises a NoSuchMethodException/IllegalArgumentException.

      Code to fix:
      EasyAntEngine.getLocalURL = conn.getClass().getMethod("getLocalURL", (Class<?>) null)
      URL localJarUrl = (URL) getLocalURL.invoke(conn, (Class<?>) null)

      Fixed code:
      EasyAntEngine.getLocalURL = conn.getClass().getMethod("getLocalURL", null)
      URL localJarUrl = (URL) getLocalURL.invoke(conn, null)

      Reason:
      From JES2 1.7 Javadoc, calling getMethod or invoke with no varArg or a null varArg is treated as if the method was called with an empty array (compliance with JES2 1.5).
      But calling those methods with a null varArg that is casted to Class<?> is treated as an array of Class<?> that contains one null element. So there is no matching method, hence the NoSuchMethodException/IllegalArgumentException.

      see also: http://stackoverflow.com/questions/5586862/weird-behaviour-of-getmethod-in-java-reflection-api-can-someone-explain-this

      Attachments

        1. ant-easyant-core-JIRA-75.patch
          1 kB
          Adrien Quillet

        Activity

          People

            jboudart Jean-Louis Boudart
            AQuillet Adrien Quillet
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified