Details
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)
}
public void testCashKey() throws SecurityException, NoSuchMethodException
{
TestClass testClass = new TestClass();
Method method = TestClass.class.getMethod("testClassArgument", new 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[]
, 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));
}