It's supposed to be connected to a truststore, and it looks up the certificate in that truststore. If not there, and it can't build a trust chain as described in the Javadoc, it returns false.
checkClientTrusted is called by a server during the handshake. checkServerTrusted is called by a client during the handshake. getAcceptedIssuers is called by both at the beginning of the handshake.