diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 5bb00a9178d..387609df4e4 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -60,6 +60,7 @@ It is shipped with the new module `pmd-css`. * core * [#5597](https://github.com/pmd/pmd/issues/5597): \[core] POM Incompatibility with Maven 4 * java + * [#5344](https://github.com/pmd/pmd/issues/5344): \[java] IllegalArgumentException: Invalid type reference for method or ctor type annotation: 16 * [#5478](https://github.com/pmd/pmd/issues/5478): \[java] Support Java 25 * java-codestyle * [#5892](https://github.com/pmd/pmd/issues/5892): \[java] ShortVariable false positive for java 22 unnamed variable `_` @@ -88,6 +89,7 @@ It is shipped with the new module `pmd-css`. * [#5893](https://github.com/pmd/pmd/pull/5893): chore: Fix Mockito javaagent warning for Java 21+ - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5894](https://github.com/pmd/pmd/pull/5894): chore: Fix JUnit warning about invalid test factory - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5895](https://github.com/pmd/pmd/pull/5895): Fix #5597: Move dogfood profile to separate settings.xml - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5899](https://github.com/pmd/pmd/pull/5899): Fix #5344: \[java] Just log invalid annotation target type - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5914](https://github.com/pmd/pmd/pull/5914): Fix #5892: \[java] ShortVariable FP for java 22 Unnamed Variable - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) ### 📦 Dependency updates diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/GenericSigBase.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/GenericSigBase.java index 86b25d847e6..4d0dfe00a68 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/GenericSigBase.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/GenericSigBase.java @@ -17,6 +17,8 @@ import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.TypePath; import org.objectweb.asm.TypeReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JTypeParameterOwnerSymbol; @@ -34,6 +36,8 @@ import net.sourceforge.pmd.util.CollectionUtil; abstract class GenericSigBase { + private static final Logger LOGGER = LoggerFactory.getLogger(GenericSigBase.class); + /* Signatures must be parsed lazily, because at the point we see them in the file, the enclosing class might not yet have been encountered @@ -408,9 +412,18 @@ boolean acceptAnnotationAfterParse(TypeReference tyRef, @Nullable TypePath path, receiverAnnotations.add(path, annot); return false; } + case TypeReference.CLASS_EXTENDS: { + // avoid exception for Java 11 bug + // see https://github.com/pmd/pmd/issues/5344 and https://bugs.openjdk.org/browse/JDK-8198945 + LOGGER.debug("Invalid target type CLASS_EXTENDS of type annotation {} for method or ctor detected. " + + "The annotation is ignored. Method: {}#{}. See https://github.com/pmd/pmd/issues/5344.", + annot, ctx.getEnclosingClass().getCanonicalName(), ctx.getSimpleName()); + return false; + } default: throw new IllegalArgumentException( - "Invalid type reference for method or ctor type annotation: " + tyRef.getSort()); + "Invalid target type of type annotation " + annot + " for method or ctor type annotation: " + + tyRef.getSort()); } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy