如何燮preSS"未知枚举常量"警告? [英] How to suppress "unknown enum constant" warnings?
问题描述
的跳棋框架引用 java.lang.annotation中.ElementType.TYPE_USE
这是在JDK8增加。当我使用它JDK7下,我得到以下警告:
The Checkers Framework references java.lang.annotation.ElementType.TYPE_USE
which was added in JDK8. When I use it under JDK7, I get the following warning:
未知的枚举常量java.lang.annotation.ElementType.TYPE_USE
这是一个合理的警告,但是如何我想喝preSS它,我相信这样的情况无害
This is a reasonable warning, but how do I suppress it for cases I believe are harmless?
推荐答案
原来有一个无害的未知枚举常量没有这样的事情。一旦我过去的编译器警告,我遇到了异常在运行时:
It turns out there is no such thing as a harmless unknown enum constant. Once I got past the compiler warnings, I ran into exceptions at runtime:
java.lang.ArrayStoreException: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseEnumArray(AnnotationParser.java:693) ~[na:1.7.0_40]
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:482) ~[na:1.7.0_40]
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:306) ~[na:1.7.0_40]
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:241) ~[na:1.7.0_40]
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88) ~[na:1.7.0_40]
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70) ~[na:1.7.0_40]
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3168) ~[na:1.7.0_40]
at java.lang.Class.getAnnotation(Class.java:3127) ~[na:1.7.0_40]
at sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:131) ~[na:1.7.0_40]
at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:84) ~[na:1.7.0_40]
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:221) ~[na:1.7.0_40]
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88) ~[na:1.7.0_40]
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70) ~[na:1.7.0_40]
at java.lang.reflect.Method.declaredAnnotations(Method.java:714) ~[na:1.7.0_40]
at java.lang.reflect.Method.getAnnotation(Method.java:700) ~[na:1.7.0_40]
at com.google.inject.spi.InjectionPoint.getAtInject(InjectionPoint.java:466) ~[guice-3.0-no_aop.jar:na]
at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:664) ~[guice-3.0-no_aop.jar:na]
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:356) ~[guice-3.0-no_aop.jar:na]
at com.google.inject.internal.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:90) ~[guice-3.0-no_aop.jar:na]
at com.google.inject.internal.MembersInjectorStore.access$000(MembersInjectorStore.java:34) ~[guice-3.0-no_aop.jar:na]
at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:42) ~[guice-3.0-no_aop.jar:na]
at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:39) ~[guice-3.0-no_aop.jar:na]
at com.google.inject.internal.FailableCache$1.apply(FailableCache.java:39) ~[guice-3.0-no_aop.jar:na]
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:549) ~[guice-3.0-no_aop.jar:na]
... 102 common frames omitted
含义,使用 java.lang.reflect.Method.getAnnotation()
将在运行时失败。
在我的情况下,这个问题是由引起HTTPS://$c$c.google.com/p/checker-framework/issues/detail ID = 255
In my case, this issue was caused by https://code.google.com/p/checker-framework/issues/detail?id=255
这篇关于如何燮preSS&QUOT;未知枚举常量&QUOT;警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!