Java 如何解决“类的表达式需要未经检查的转换才能符合类”

Java 如何解决“类的表达式需要未经检查的转换才能符合类”,java,junit,mockito,powermock,data-access,Java,Junit,Mockito,Powermock,Data Access,我有最新消息。试验方法: @Mock private DBAccessor accessor; /** * Successful find(). */ @Test public void testFind() { // Prepare MockDto mockDto = mock(MockDto.class); try { when(accessor.executeQuery(any(Class.class), anyString(), any(Co

我有最新消息。试验方法:

@Mock
private DBAccessor accessor;

/**
 * Successful find().
 */
@Test
public void testFind() {
    // Prepare
    MockDto mockDto = mock(MockDto.class);
    try {
        when(accessor.executeQuery(any(Class.class), anyString(), any(ConcurrentHashMap.class))).thenReturn(
                mockDto);
    } catch (Exception e) {
        fail("Unexpected exception.");
    }
}
然而,ff。警告事件:

Multiple markers at this line
    - Type safety: Unchecked invocation executeQuery(Class, String, ConcurrentHashMap) of the generic method executeQuery(Class<T>, String, Object) of type DBAccessor
    - Type safety: The expression of type Class needs unchecked conversion to conform to Class<Object>
如何解决上述警告


我使用Mockit和Powermock作为模拟框架和JUnit。

如ff中所示,可以通过@suppressWarningunchecked将其删除。

@suppressWarningunchecked?谢谢。刚刚从这里找到了答案: