Here you can find the source of isCompatible(Class actualType, Class parameterType)
public static boolean isCompatible(Class actualType, Class parameterType)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.util.HashMap; import java.util.Map; public class Main { /**/*from w w w .j a v a2 s .co m*/ * Map from primitive type to wrapper type. */ private static final Map _primitiveMap = new HashMap(); public static boolean isCompatible(Class actualType, Class parameterType) { if (actualType.isAssignableFrom(parameterType)) return true; // Reflection fudges the assignment of a wrapper class to a primitive // type ... we check for that the hard way. if (actualType.isPrimitive()) { Class wrapperClass = (Class) _primitiveMap.get(actualType); return wrapperClass.isAssignableFrom(parameterType); } return false; } }