1. 程式人生 > >Java8 移除了APT以及mirror API後,使用Pluggable Annotation Processing API

Java8 移除了APT以及mirror API後,使用Pluggable Annotation Processing API

官方原文:

Goals:

By removing apt from the JDK, annotation processing can finish transitioning
to the superior, standardized JSR 269 API.

The apt annotation processing framework is JDK-specific and dates back to JDK
5. The functionality of the API was standardized with JSR 269, which shipped
as part of Java SE 6. In JDK 7, the entirety of the apt API was deprecated.

Impacts:

After this change, users of annotation processing will have to use the JSR
269 annotation processing facility, which has been supported in javac since
JDK 6. Since apt is just part of the JDK and not part of Java SE, there is a
looser compatibility contract around this component than around an API in
java.* or javax.*. The removal of a command line tool from the JDK is not
unprecedented, but the removal of apt should be clearly described in the
release notes and similar documents.

意味著Java8以後不再預設包含APT了,並且相關的資源都被移除了比如Mirror相關類,取而代之的是Pluggable Annotation Processing API,新的API使用方式略有不同,但是思想統一,操作起來還是比較方便的。

學習資源:

最近就使用新的Pluggable Annotation Processing API寫了一個編譯時註解處理的庫,感興趣的可以去github(地址)下載,拜託給個Start吧/(ㄒoㄒ)/~~,寫了好久了,有任何問題,歡迎留言~