java 9 module-info annotation access_flag ACC_MODULE设置错误

时间:2017-08-19 15:50:47

标签: java annotations java-9

我有以下注释

@Retention(RUNTIME)
@Target({PACKAGE, MODULE, TYPE})
public @interface Version {
    int major();
    int minor();
}

我在 module-info.java 中使用

@Deprecated(since = "1.2", forRemoval = false)
@SuppressWarnings("unchecked")
@Version(major = 1, minor = 2)
module com.jdojo.module.api.annotation {}

然后在包com.jdojo.module.api.annotation内部我再次调用模块的注释

public class AnnotationTest {
    public static void main(String[] args) {
        Module m = AnnotationTest.class.getModule();
        Annotation[] ann = m.getAnnotations();
    }
}

@ m.getAnnotations()我有错误Exception in thread "main" java.lang.NoClassDefFoundError: module-info is not a class because access_flag ACC_MODULE is set

0 个答案:

没有答案