apache/maven · warning

Unknown default reference type, using HARD

Error message

Unknown default reference type, using HARD

What it means

DefaultModelObjectPool picks the default reference strength for pooled model objects from the system property 'maven.model.processor.referenceType' (Constants.MAVEN_MODEL_PROCESSOR_REFERENCE_TYPE), defaulting to HARD. If the configured string is not a Cache.ReferenceType name (NONE, SOFT, WEAK, HARD), valueOf() throws IllegalArgumentException, this warn is logged, and HARD references are used as a safe fallback.

Source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelObjectPool.java:149

            } catch (IllegalArgumentException e) {
                LOGGER.warn("Unknown reference type for " + className + ": " + perTypeValue + ", using default");
            }
        }

        // Fall back to default reference type
        return getDefaultReferenceType();
    }

    /**
     * Gets the default reference type from system properties.
     */
    private Cache.ReferenceType getDefaultReferenceType() {
        try {
            String referenceTypeProperty =
                    getProperty(Constants.MAVEN_MODEL_PROCESSOR_REFERENCE_TYPE, Cache.ReferenceType.HARD.name());
            return Cache.ReferenceType.valueOf(referenceTypeProperty.toUpperCase());
        } catch (IllegalArgumentException e) {
            LOGGER.warn("Unknown default reference type, using HARD");
            return Cache.ReferenceType.HARD;
        }
    }

    /**
     * Interns an object in the appropriate pool.
     */
    private Object internObject(Object object, Cache<PoolKey, Object> cache, Class<?> objectType) {
        // Update statistics
        TOTAL_CALLS.computeIfAbsent(objectType, k -> new AtomicLong(0)).incrementAndGet();

        PoolKey key = new PoolKey(object);
        Object existing = cache.get(key);
        if (existing != null) {
            CACHE_HITS.computeIfAbsent(objectType, k -> new AtomicLong(0)).incrementAndGet();
            return existing;
        }

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Use an exact enum name: -Dmaven.model.processor.referenceType=SOFT (NONE, SOFT, WEAK, HARD; any case)
  2. Trim whitespace and remove quotes from the value wherever it is defined (MAVEN_OPTS, jvm.config, CI env var)
  3. Remove the property to accept the documented default HARD

Example fix

# before
MAVEN_OPTS="-Dmaven.model.processor.referenceType=weakref"

# after
MAVEN_OPTS="-Dmaven.model.processor.referenceType=WEAK"
Defensive patterns

Strategy: validation

Validate before calling

static final Set<String> VALID_REF_TYPES = Set.of("NONE", "SOFT", "WEAK", "HARD");

static void checkDefaultRefType(java.util.Properties props) {
    String v = props.getProperty("maven.model.processor.referenceType");
    if (v != null && !VALID_REF_TYPES.contains(v.strip().toUpperCase(Locale.ROOT))) {
        throw new IllegalArgumentException("maven.model.processor.referenceType must be one of " + VALID_REF_TYPES);
    }
}

Prevention

When it happens

Trigger: Launching Maven with -Dmaven.model.processor.referenceType=<invalid> (e.g. 'soft ', 'PHANTOM', 'weakref'). getDefaultReferenceType() is read whenever no valid per-type override exists, so every pooled class uses HARD after the fallback.

Common situations: Typos in MAVEN_OPTS/.mvn/jvm.config/CI settings; documentation copied from ehcache or Guava cache tuning (different vocabulary); values with trailing whitespace from YAML or property files, which toUpperCase() does not strip.

Related errors


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