public class NotifyConstants {
public enum METHOD {
TEST("TEST","TEST");
private String code;
private String name;
METHOD(String code, String name) {
this.code = code;
this.name = name;
}
//getter setter...
}
我有一个像这样的类,我可以用maven编译它。但是当我使用MethodInvocationProcessor钩住编译过程时
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessors>
<annotationProcessor>
xxx.MethodInvocationProcessor
</annotationProcessor>
</annotationProcessors>
</configuration>
<version>3.5.1</version>
</plugin>
我遇到了错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project xxxx-manage: Compilation failure: Compilation failure:
[ERROR] /D:/Workspace/master/xxxx-manage/xxxxx/NotifyConstants.java:[19,50] call to super not allowed in enum constructor
第19行是我的构造函数的第一行
OPENAPI_METHOD(String code, String name) {
我知道JVM默认在子类构造函数的第一行中插入'super()'语句(如果您没有),但是为什么我可以在没有MethodInvocationProcessor钩子的情况下进行编译?我该如何解决呢?