apache/iceberg · warning · UnsupportedOperationException

org.apache.iceberg.arrow.vectorized.ArrowVectorAccessors can

Error message

org.apache.iceberg.arrow.vectorized.ArrowVectorAccessors cannot be instantiated.

What it means

ArrowVectorAccessors is a static-utility holder (its constructor is private and intentionally throws). Any attempt to instantiate it via reflection or new reaches this guard. This is an anti-instantiation idiom protecting a class that only exposes static factory methods like getVectorAccessor.

Source

Thrown at arrow/src/main/java/org/apache/iceberg/arrow/vectorized/ArrowVectorAccessors.java:49

  private static final GenericArrowVectorAccessorFactory<?, String, ?, ?> FACTORY;

  static {
    FACTORY =
        new GenericArrowVectorAccessorFactory<>(
            JavaDecimalFactory::new,
            JavaStringFactory::new,
            throwingSupplier("Struct type is not supported"),
            throwingSupplier("List type is not supported"));
  }

  private static <T> Supplier<T> throwingSupplier(String message) {
    return () -> {
      throw new UnsupportedOperationException(message);
    };
  }

  private ArrowVectorAccessors() {
    throw new UnsupportedOperationException(
        ArrowVectorAccessors.class.getName() + " cannot be instantiated.");
  }

  static ArrowVectorAccessor<?, String, ?, ?> getVectorAccessor(VectorHolder holder) {
    return FACTORY.getVectorAccessor(holder);
  }

  private static final class JavaStringFactory implements StringFactory<String> {
    @Override
    public Class<String> getGenericClass() {
      return String.class;
    }

    @Override
    public String ofRow(VarCharVector vector, int rowId) {
      return ofBytes(vector.get(rowId));
    }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Use the static methods (ArrowVectorAccessors.getVectorAccessor(holder)) instead of instantiating the class
  2. Exclude utility classes from reflection-based instantiation/scanning
  3. Mark the class final/private-constructor usage correctly in framework configs

Example fix

// before
ArrowVectorAccessors accessors = ctor.newInstance(); // throws
// after
ArrowVectorAccessor<?, String, ?, ?> a = ArrowVectorAccessors.getVectorAccessor(holder);
Defensive patterns

Strategy: type-guard

Type guard

boolean isUtilityClass(Class<?> c) { try { c.getDeclaredConstructor(); return c.getDeclaredConstructor().canAccess(null) == false; } catch (NoSuchMethodException e) { return true; } }

Try / catch

try { ctor.setAccessible(true); ctor.newInstance(); } catch (InvocationTargetException e) { /* use static methods instead */ }

Prevention

When it happens

Trigger: Calling new ArrowVectorAccessors() (blocked at compile time, so realistically via reflection, serialization frameworks, or code generators), or frameworks that force instantiation of classes found by classpath scanning.

Common situations: Reflection-based utilities (e.g. Class.newInstance in old serialization or DI frameworks) touching the class; accidentally treating the utility class as a bean.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/a52c9e425e392d00. Report an issue: GitHub.