Skip to content

Fix #5344: [java] Just log invalid annotation target type #5899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix #5344: [java] Just log invalid annotation target type
No error is logged anymore.
  • Loading branch information
adangel committed Jul 11, 2025
commit bc3f27517b4dc306454a3ec0a321f9712d67cfef
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,6 +36,8 @@
import net.sourceforge.pmd.util.CollectionUtil;

abstract class GenericSigBase<T extends JTypeParameterOwnerSymbol & AsmStub> {
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
Expand Down Expand Up @@ -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());
}
}

Expand Down
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