spring-projects/spring-framework · error · IntrospectionException

Non int index to indexed read method: {}

Error message

Non int index to indexed read method: {}

What it means

Thrown as java.beans.IntrospectionException by PropertyDescriptorUtils.findIndexedPropertyType when the indexed read method's single parameter is not of type int. JavaBeans indexed accessors require the index parameter to be int.

Source

Thrown at spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java:203

		return propertyType;
	}

	/**
	 * See {@link java.beans.IndexedPropertyDescriptor#findIndexedPropertyType}.
	 */
	public static @Nullable Class<?> findIndexedPropertyType(String name, @Nullable Class<?> propertyType,
			@Nullable Method indexedReadMethod, @Nullable Method indexedWriteMethod) throws IntrospectionException {

		Class<?> indexedPropertyType = null;

		if (indexedReadMethod != null) {
			Class<?>[] params = indexedReadMethod.getParameterTypes();
			if (params.length != 1) {
				throw new IntrospectionException("Bad indexed read method arg count: " + indexedReadMethod);
			}
			if (params[0] != int.class) {
				throw new IntrospectionException("Non int index to indexed read method: " + indexedReadMethod);
			}
			indexedPropertyType = indexedReadMethod.getReturnType();
			if (indexedPropertyType == void.class) {
				throw new IntrospectionException("Indexed read method returns void: " + indexedReadMethod);
			}
		}

		if (indexedWriteMethod != null) {
			Class<?>[] params = indexedWriteMethod.getParameterTypes();
			if (params.length != 2) {
				throw new IntrospectionException("Bad indexed write method arg count: " + indexedWriteMethod);
			}
			if (params[0] != int.class) {
				throw new IntrospectionException("Non int index to indexed write method: " + indexedWriteMethod);
			}
			if (indexedPropertyType != null) {
				if (indexedPropertyType.isAssignableFrom(params[1])) {
					// Write method's property type potentially more specific

View on GitHub (pinned to 69bf83ad71)

Solutions

  1. Change the indexed getter's index parameter to int: Type getXxx(int i).
  2. If you need a non-int key, do not model it as a JavaBeans indexed property; use a Map-typed simple property instead.
  3. Correct or regenerate the offending class.

Example fix

// before
public Item getItem(long index); // non-int index

// after
public Item getItem(int index);
Defensive patterns

Strategy: validation

Validate before calling

if (indexedReadMethod != null && indexedReadMethod.getParameterTypes()[0] != int.class) {
    throw new IllegalArgumentException("indexed getter index must be int: " + indexedReadMethod);
}

Type guard

static boolean indexedReadUsesInt(Method m) {
    return m != null && m.getParameterCount() == 1 && m.getParameterTypes()[0] == int.class;
}

Prevention

When it happens

Trigger: findIndexedPropertyType called with an indexedReadMethod whose single param is not int.class (e.g. long, Integer, String).

Common situations: An overloaded accessor getXxx(long) or getXxx(Integer), a custom indexing scheme using a non-int key, or generated code using the wrong index type.

Related errors


AI-assisted analysis of spring-projects/spring-framework@69bf83ad71 (2026-08-09). Data as JSON: /api/errors/9182b1ec13d3a427. Report an issue: GitHub.