解决:高版本jdk编译低版本代码时eclipse提示Access restriction:The type 'Unsafe' is not accessible due to restriction on required library

时间:2023-03-09 21:39:41
解决:高版本jdk编译低版本代码时eclipse提示Access restriction:The type 'Unsafe' is not accessible due to restriction on  required library

在Eclipse中采用高版本jdk编译一些低版本的源码时,由于源码中使用了一些高版本中过时的API,可能就会报错,类似于:

Access restriction:The type 'Unsafe' is not accessible due to restriction on  required library。。。。

简单解决方法是修改编译器编译的配置:

设置 Windows->Preferences->Java-Complicer->Errors/Warnings->Deprecated and restricted API ->Forbidden references(access rules)为Warning,重新编译即。

如图:解决:高版本jdk编译低版本代码时eclipse提示Access restriction:The type 'Unsafe' is not accessible due to restriction on  required library