The drawbacks of annotation processing in Java?

前端 未结 3 2053
猫巷女王i
猫巷女王i 2021-01-30 02:21

I am considering starting a project which is used to generate code in Java using annotations (I won\'t get into specifics, as it\'s not really relevant). I am wondering about th

3条回答
  •  花落未央
    2021-01-30 03:00

    One specific which would be helpful in answering the question would be as opposed to what? Not doing the project, or doing it not using annotations? And if not using annotations, what are the alternatives?

    Personally, I find excessive annotations unreadable, and many times too inflexible. Take a look at this for one method on a web service to implement a vendor required WSDL:

        @WebMethod(action=QBWSBean.NS+"receiveResponseXML")
    @WebResult(name="receiveResponseXML"+result,targetNamespace = QBWSBean.NS)
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public int receiveResponseXML(
            @WebParam(name = "ticket",targetNamespace = QBWSBean.NS) String ticket,
            @WebParam(name = "response",targetNamespace = QBWSBean.NS) String response,
            @WebParam(name = "hresult",targetNamespace = QBWSBean.NS) String hresult,
            @WebParam(name = "message",targetNamespace = QBWSBean.NS) String message) {
    

    I find that code highly unreadable. An XML configuration alternative isn't necessarily better, though.

提交回复
热议问题