What is annotation processing in Java?

2019-02-04 17:02发布

Quoting, Sun's Official Java Tutorial

Class names, 'HelloWorldApp', are only accepted if annotation processing is explicitly requested

What does it mean? And how to apply it?

3条回答
走好不送
2楼-- · 2019-02-04 17:45

This error is due to incorrect use of java compilation command i.e javac with file name w/o java extension (.java)

Use proper compilation command

javac HelloWorldApp.java

Command used foe execution

java HelloWorldApp

查看更多
等我变得足够好
3楼-- · 2019-02-04 17:47

"Annotation Processing" is a hook into the compile process of the java compiler, to analyse the source code for user defined annotations and handle then (by producing compiler errors, compiler warning, emitting source code, byte code ...).

API reference: http://java.sun.com/javase/6/docs/api/javax/annotation/processing/package-summary.html

查看更多
该账号已被封号
4楼-- · 2019-02-04 17:50

From the very next line of the page that you refer to:

Class names, 'HelloWorldApp', are only accepted if annotation processing is explicitly requested

If you receive this error, you forgot to include the .java suffix when compiling the program. Remember, the command is javac HelloWorldApp.java not javac HelloWorldApp.

That is, the string that you are referring to is a possible error that you might get when trying to compile the examples. The very next line in the document, tells you how to resolve the issue.

If you want to know more about annotations, what they are, and how to use them, then I would suggest to go through the Annotations tutorial.

查看更多
登录 后发表回答