Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



你可以运行以下命令对GitHub Alibaba组织下的所有Java非Android项目运行p3c规范检查:

groovy DoesAlibabaFollowTheirOwnGuidelines.groovy


groovy -DminimumPriority=1 DoesAlibabaFollowTheirOwnGuidelines.groovy

注意在JDK8上运行,因为有些项目的构建不支持11;同时保证PATH中包含mvngit。这会对所有的项目运行mvn clean install -DskipTests,期间会执行mvn pmd:check

项目名 是否使用了pmd-p3c default -DminimumPriority=1 PR及状态 备注
fastjson 2926 PMD violations 91 PMD violations Open:
druid 10066 PMD violations 216 PMD violations Open:
arthas ? PMD violations build successful Merged:
canal 42 PMD violations 3 PMD violations
fescar ? PMD violations build successful Merged:
Sentinel ? PMD violations build successful Merged:
nacos build successful build successful
otter build failure build failure
easyexcel 44 PMD violations build successful
jstorm 19183 PMD violations 2593 PMD violations
cobar-driver 35 PMD violations 1 PMD violations
cobar-server 2327 PMD violations 356 PMD violations
cobar-manager 346 PMD violations 47 PMD violations
jvm-sandbox 20 PMD violations 11 PMD violations
DataX 179 PMD violations 6 PMD violations
TProfiler 70 PMD violations 2 PMD violations
dubbo-spring-boot-starter 9 PMD violations build successful
jetcache 5 PMD violations 2 PMD violations
mdrill-trunk 4442 PMD violations 713 PMD violations
yugong 297 PMD violations 82 PMD violations
QLExpress 637 PMD violations 169 PMD violations
taokeeper build failure build failure
simpleimage build failure unknown
asyncload 112 PMD violations 1 PMD violations
p3c-eclipse-plugin build successful build successful
p3c-p3c-pmd 2 PMD violations build successful Open:




  • 在上面的列表中挑选一个你喜欢的、未使用p3c-pmd的项目。注意选择活跃项目,否则可能处于无人维护状态,这可以通过项目提交状态甄别。
  • pom.xml中加入:
  • 运行mvn clean install -DskipTests -DminimumPriority=1,修正列出的violations。如果你拿不准如何修改,可以使用@SuppressWarnings("PMD.<RuleName>")(这是编译期注解,放心使用),这样至少可以保证未来的代码不会变得更差。
  • 提交PR。
  • 加分项:你可以尝试不加-DminimumPriority=1,修正所有violations。代价是工作量可能增长数倍。


2018年9月22日,在2018杭州云栖大会上,召开《码出高效:Java 开发手册》新书发布会,并宣布将图书所有收益均捐赠于技术公益项目“83行代码计划”。






We are pleased to present Alibaba Java Coding Guidelines which consolidates the best programming practices over the years from Alibaba Group's technical teams. A vast number of Java programming teams impose demanding requirements on code quality across projects as we encourage reuse and better understanding of each other's programs. We have seen many programming problems in the past. For example, defective database table structures and index designs may cause software architecture flaws and performance risks. Another example is confusing code structures being difficult to maintain. Furthermore, vulnerable code without authentication is prone to hackers’ attacks. To address these kinds of problems, we developed this document for Java developers at Alibaba.

For more information please refer the Alibaba Java Coding Guidelines:


The project consists of 3 parts:


Forty-nine rules are realized based on PMD, please refer the P3C-PMD documentation for more detailed information. Four rules are implemented within IDE plugins (IDEA and Eclipse) as follows:

  • [Mandatory] Using a deprecated class or method is prohibited.
    Note: For example, decode(String source, String encode) should be used instead of the deprecated method decode(String encodeStr). Once an interface has been deprecated, the interface provider has the obligation to provide a new one. At the same time, client programmers have the obligation to check out what its new implementation is.

  • [Mandatory] An overridden method from an interface or abstract class must be marked with @Override annotation. Counter example: For getObject() and get0bject(), the first one has a letter 'O', and the second one has a number '0'. To accurately determine whether the overriding is successful, an @Override annotation is necessary. Meanwhile, once the method signature in the abstract class is changed, the implementation class will report a compile-time error immediately.

  • [Mandatory] A static field or method should be directly referred by its class name instead of its corresponding object name.

  • [Mandatory] The usage of hashCode and equals should follow:

    1. Override hashCode if equals is overridden.
    2. These two methods must be overridden for Set since they are used to ensure that no duplicate object will be inserted in Set.
    3. These two methods must be overridden if self-defined object is used as the key of Map. Note: String can be used as the key of Map since these two methods have been rewritten.

Join us

If you have any questions or comments, please contact junlie by email at, and please join us to make project P3C perfect for more programmers.

Please follow our WeChat official account as ali_yunxiao below:

You can’t perform that action at this time.