Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
JDK 8 project, NetBeans running on JDK 13
Description
In an annotation processor similar to
@SupportedAnnotationTypes("org.example.MyAnnotation") public final class MyGenerator extends javax.annotation.processing.AbstractProcessor { @Override public boolean process( final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnvironment) { final Set<? extends Element> elements = roundEnvironment.getElementsAnnotatedWith(MyAnnotation.class); for (final Element element : elements) { PackageElement packageElement = null; for (Element currentElement = typeElement; currentElement != null; currentElement = currentElement.getEnclosingElement()) { if (currentElement instanceof PackageElement) { // Illegal Use of instanceOf packageElement = (PackageElement) currentElement; break; }
I get the warning “Illegal Use of instanceOf operator” (in the line with the comment). It is unclear why this use would be illegal, as it works fine.
The description of the hint in the options should clearly say why it’s illegal to use instanceOf or, if this warning is obsolete, the hint should be removed.
(According to http://wiki.netbeans.org/Java_Hints, this hint is disabled by default.)