You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An exception is thrown when processing code using generic wildcards and self-referential generic bounds. This bug does not occur if the parent type is declared as an interface.
classParent<TextendsParent<T>> {} // Recursive type TclassChildextendsParent<Child> {}
classBox<TextendsParent<T>> {
publicvoidfoo(Box<? extendsChild> box) {} // <-- The bug is triggered by this line
}
Exception Stacktrace:
ContextedRuntimeException: java.lang.IllegalArgumentException: Bad intersection, unrelated class types Child and Parent<capture#225 of ? extends Child> in [Parent<capture#225 of ? extends Child>, Child]
Exception Context:
[1:Rule applied on node=!debug only! [MethodDeclaration:309:15]public void foo(Box<? extends Child> box) {}]
org.apache.commons.lang3.exception.ContextedRuntimeException: java.lang.IllegalArgumentException: Bad intersection, unrelated class types Child and Parent<capture#225 of ? extends Child> in [Parent<capture#225 of ? extends Child>, Child]
Exception Context:
[1:Rule applied on node=!debug only! [MethodDeclaration:309:15]public void foo(Box<? extends Child> box) {}]
---------------------------------
at net.sourceforge.pmd.util.AssertionUtil.contexted(AssertionUtil.java:236)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex(RuleApplicator.java:79)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply(RuleApplicator.java:57)
at net.sourceforge.pmd.lang.rule.internal.RuleSets.apply(RuleSets.java:155)
at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource(PmdRunnable.java:140)
at net.sourceforge.pmd.lang.impl.PmdRunnable.run(PmdRunnable.java:80)
at java.base@17.0.8.1/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base@17.0.8.1/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base@17.0.8.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base@17.0.8.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base@17.0.8.1/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalArgumentException: Bad intersection, unrelated class types Child and Parent<capture#225 of ? extends Child> in [Parent<capture#225 of ? extends Child>, Child]
at net.sourceforge.pmd.lang.java.types.Lub.glb(Lub.java:344)
at net.sourceforge.pmd.lang.java.types.TypeSystem.glb(TypeSystem.java:723)
at net.sourceforge.pmd.lang.java.types.TypeConversion.capture(TypeConversion.java:227)
at net.sourceforge.pmd.lang.java.types.TypeConversion.capture(TypeConversion.java:154)
at net.sourceforge.pmd.lang.java.types.TypeOps.isConvertible(TypeOps.java:462)
at net.sourceforge.pmd.lang.java.types.TypeOps.isConvertible(TypeOps.java:401)
at net.sourceforge.pmd.lang.java.types.JTypeMirror.isConvertibleTo(JTypeMirror.java:126)
at net.sourceforge.pmd.lang.java.types.JTypeMirror.isSubtypeOf(JTypeMirror.java:114)
at net.sourceforge.pmd.lang.java.types.TypeTestUtil.isA(TypeTestUtil.java:158)
at net.sourceforge.pmd.lang.java.types.TypeTestUtil.isA(TypeTestUtil.java:178)
at net.sourceforge.pmd.lang.java.types.TypeTestUtil.isA(TypeTestUtil.java:122)
at net.sourceforge.pmd.lang.java.rule.xpath.internal.BaseContextNodeTestFun.lambda$makeCallExpression$1(BaseContextNodeTestFun.java:57)
at net.sourceforge.pmd.lang.rule.xpath.internal.SaxonExtensionFunctionDefinitionAdapter$1.call(SaxonExtensionFunctionDefinitionAdapter.java:135)
at net.sf.saxon.lib.ExtensionFunctionCall.effectiveBooleanValue(ExtensionFunctionCall.java:189)
at net.sf.saxon.functions.IntegratedFunctionCall.effectiveBooleanValue(IntegratedFunctionCall.java:377)
at net.sf.saxon.expr.elab.FallbackElaborator.lambda$elaborateForBoolean$3(FallbackElaborator.java:61)
at net.sf.saxon.expr.FilterExpression$FilterExprElaborator$SimpleFilteredIterator.next(FilterExpression.java:1376)
at net.sf.saxon.expr.ContextMappingIterator.next(ContextMappingIterator.java:67)
at net.sf.saxon.functions.Count.count(Count.java:66)
at net.sf.saxon.functions.Count$CountFnElaborator.lambda$elaborateForItem$0(Count.java:130)
at net.sf.saxon.expr.ValueComparison$ValueComparisonElaborator.lambda$elaborateForItem$1(ValueComparison.java:546)
at net.sf.saxon.expr.elab.ItemElaborator.lambda$elaborateForPull$0(ItemElaborator.java:36)
at net.sf.saxon.expr.FilterExpression$FilterExprElaborator$PositionalFilteredIterator.next(FilterExpression.java:1330)
at net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery.evaluate(SaxonXPathRuleQuery.java:128)
at net.sourceforge.pmd.lang.rule.xpath.XPathRule.apply(XPathRule.java:101)
at net.sourceforge.pmd.lang.rule.RuleReference.apply(RuleReference.java:415)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex(RuleApplicator.java:77)
... 9 more
Exception occurred on node !debug only! [MethodDeclaration:309:15]public void foo(Box<? extends Child> box) {}
Code Sample demonstrating the issue:
See above
Steps to reproduce:
Run PMD on the code sample
Running PMD through:
Gradle 8.5, on openjdk 17.0.8.1 2023-08-24
The text was updated successfully, but these errors were encountered:
Affects PMD Version:
7.1.0
Description:
An exception is thrown when processing code using generic wildcards and self-referential generic bounds. This bug does not occur if the parent type is declared as an interface.
Exception Stacktrace:
Code Sample demonstrating the issue:
See above
Steps to reproduce:
Run PMD on the code sample
Running PMD through:
Gradle 8.5, on
openjdk 17.0.8.1 2023-08-24
The text was updated successfully, but these errors were encountered: