A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/5505 below:

[java] java.lang.StackOverflowError while executing a PmdRunnable · Issue #5505 · pmd/pmd · GitHub

Affects PMD Version:

PMD 7.10.0 (db70a20, 2025-01-31T09:22:09Z)

Description:

Unknown error occurred while executing a PmdRunnable: java.lang.StackOverflowError

Exception Stacktrace:

Exception in thread "main" java.lang.StackOverflowError
        at net.sourceforge.pmd.lang.java.types.SentinelType.acceptVisitor(SentinelType.java:66)
        at net.sourceforge.pmd.lang.java.types.TypeOps.isSameType(TypeOps.java:134)
        at net.sourceforge.pmd.lang.java.types.TypeOps.access$000(TypeOps.java:50)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.typeArgContains(TypeOps.java:769)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.visitClass(TypeOps.java:854)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.visitClass(TypeOps.java:586)
        at net.sourceforge.pmd.lang.java.types.JClassType.acceptVisitor(JClassType.java:312)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.isConvertible(TypeOps.java:656)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.isConvertible(TypeOps.java:598)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.visitTypeVar(TypeOps.java:808)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.visitTypeVar(TypeOps.java:586)
        at net.sourceforge.pmd.lang.java.types.JTypeVar.acceptVisitor(JTypeVar.java:103)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.isConvertible(TypeOps.java:656)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.isConvertible(TypeOps.java:598)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.typeArgContains(TypeOps.java:788)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.visitClass(TypeOps.java:854)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.visitClass(TypeOps.java:586)
        at net.sourceforge.pmd.lang.java.types.JClassType.acceptVisitor(JClassType.java:312)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.isConvertible(TypeOps.java:656)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.isConvertible(TypeOps.java:598)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.visitTypeVar(TypeOps.java:808)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.visitTypeVar(TypeOps.java:586)
        at net.sourceforge.pmd.lang.java.types.JTypeVar.acceptVisitor(JTypeVar.java:103)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.isConvertible(TypeOps.java:656)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.isConvertible(TypeOps.java:598)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.typeArgContains(TypeOps.java:788)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.visitClass(TypeOps.java:854)
        at net.sourceforge.pmd.lang.java.types.TypeOps$SubtypeVisitor.visitClass(TypeOps.java:586)
        at net.sourceforge.pmd.lang.java.types.JClassType.acceptVisitor(JClassType.java:312)
...

Code Sample demonstrating the issue:

package org.example;

import java.util.Collection;
import java.util.Collections;
import java.util.Optional;

public class Main {

    public static <T extends Comparable<? super T>> Optional<T> getMaxElementCausesStackoverflow(Collection<? extends T> collection) {
        return collection == null || collection.isEmpty() ? Optional.empty() : Optional.of(Collections.max(collection));
    }

    public static <T extends Comparable<? super T>> Optional<T> getMaxElementIsFine(Collection<? extends T> collection) {
        return Optional.ofNullable(collection).filter(c -> !c.isEmpty()).map(Collections::max);
    }
}

Steps to reproduce:

pmd check -d ./Main.java -R rulesets/java/quickstart.xml

Running PMD through: CLI
Java version: 21.0.2, vendor: Amazon.com Inc
OS: macOS 14.5


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4