apache/maven · error · RuntimeException

Cannot convert to number: {value}

Error message

Cannot convert to number: {value}

What it means

Error "Cannot convert to number: {value}" thrown in apache/maven.

Source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java:618

     * If the object cannot be converted, a {@code RuntimeException} is thrown.
     *
     * @param value the object to convert to a double
     * @return the double representation of the object
     * @throws RuntimeException if the object cannot be converted to a double
     */
    public static double toDouble(Object value) {
        if (value instanceof Number number) {
            return number.doubleValue(); // Converts number to double
        } else if (value instanceof String string) {
            try {
                return Double.parseDouble(string); // Tries to parse string as double
            } catch (NumberFormatException e) {
                throw new RuntimeException("Cannot convert string to number: " + value);
            }
        } else if (value instanceof Boolean bool) {
            return bool ? 1.0 : 0.0; // True = 1.0, False = 0.0
        } else {
            throw new RuntimeException("Cannot convert to number: " + value);
        }
    }

    /**
     * Converts an object to an integer value.
     * If the object is:
     * - a {@code Number}, returns its integer value.
     * - a {@code String}, tries to parse it as an integer, or as a double then converted to an integer.
     * - a {@code Boolean}, returns {@code 1} for {@code true}, {@code 0} for {@code false}.
     * If the object cannot be converted, a {@code RuntimeException} is thrown.
     *
     * @param value the object to convert to an integer
     * @return the integer representation of the object
     * @throws RuntimeException if the object cannot be converted to an integer
     */
    public static int toInt(Object value) {
        if (value instanceof Number number) {
            return number.intValue(); // Converts number to int

View on GitHub (pinned to e4093d4e12)

When it happens

Trigger: Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java:618 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/e6eb4185744d458f. Report an issue: GitHub.