Uploaded image for project: 'Spring Modules'
  1. Spring Modules
  2. MOD-201

Problems with java.lang.Class Objects as method arguments

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.5
    • Fix Version/s: 0.7
    • Component/s: CACHE
    • Labels:
      None

      Description

      The HashCodeCacheKeyGenerator generates in the GenerateArgumentHashCode-Mode the same key for all java.lang.Class object arguments. The problem corresponds to MOD-200, all fields in java.lang.Class are transient or static (see special case in ObjectOutputStream).

      TestCase:

      public class TestClass
      {
      public Class testClassArgument(Class clazz)

      { return clazz; }

      }

      public void testCashKey() throws SecurityException, NoSuchMethodException
      {
      TestClass testClass = new TestClass();
      Method method = TestClass.class.getMethod("testClassArgument", new Class[]

      {Class.class}

      );

      MethodInvocation mi0 = new ReflectiveMethodInvocation(null /* proxy has no test influence */, testClass, method, new Object[]

      {String.class}

      , TestClass.class, Collections.EMPTY_LIST);
      MethodInvocation mi1 = new ReflectiveMethodInvocation(null /* proxy has no test influence */, testClass, method, new Object[]

      {List.class}

      , TestClass.class, Collections.EMPTY_LIST);

      HashCodeCacheKeyGenerator keyGenerator = new HashCodeCacheKeyGenerator();
      keyGenerator.setGenerateArgumentHashCode(true);

      Serializable key0 = keyGenerator.generateKey(mi0);
      Serializable key1 = keyGenerator.generateKey(mi1);

      System.out.println("testClassArgument(String.class) (" + key0 + ")" + " != testClassArgument(List.class) (" + key1 + ")" );
      assertFalse(key0.equals(key1));
      }

        Attachments

          Activity

            People

            Assignee:
            irbouho Omar Irbouh
            Reporter:
            magtas Markus Rogg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: