What is the clearest way to deprecate a package in Java?

前端 未结 6 553
孤独总比滥情好
孤独总比滥情好 2020-12-15 03:19

I\'m working on a new codebase and migrating the system to a new framework.

There are a number of packages that I would like to deprecate, just to make it very clear

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 03:28

    Use AspectJ. Create an Aspect that issues a compiler warning when the package is used:

    public aspect DeprecationAspect{
    
        declare warning :
            call(* foo.bar..*(..)) : "Package foo.bar is deprecated";
    
    }
    

    (You can easily add AspectJ to your build if you use ant or maven)

提交回复
热议问题