方法:打印出这个类的类加载器可判断:类.class.getClassLoader();
,核心类库加载器会返回:null
/**
* 判断一个类是JAVA类型还是用户定义类型
* @param clz
* @return
*/
public static boolean isJavaClass(Class<?> clz) {
return clz != null && clz.getClassLoader() == null;
}
public static void main(String... args) {
System.out.println(isJavaClass(Integer.class)); // true
System.out.println(isJavaClass(BugMeNot.class)); // false
}
https://blog.csdn.net/sinat_33852001/article/details/82492949
https://blog.csdn.net/redennc/article/details/22620875
https://blog.csdn.net/oygen/article/details/88330292
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/281844.html