{"record":{"id":"f017bd9fd08e57aa","repo":"apache/iceberg","slug":"cannot-find-method-name","errorCode":null,"errorMessage":"Cannot find method: ${name}","messagePattern":"Cannot find method: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/org/apache/iceberg/common/DynMethods.java","lineNumber":468,"sourceCode":"     * @see java.lang.Class#getMethod(String, Class[])\n     */\n    public Builder hiddenImpl(Class<?> targetClass, Class<?>... argClasses) {\n      hiddenImpl(targetClass, name, argClasses);\n      return this;\n    }\n\n    /**\n     * Returns the first valid implementation as a UnboundMethod or throws a RuntimeError if there\n     * is none.\n     *\n     * @return a {@link UnboundMethod} with a valid implementation\n     * @throws RuntimeException if no implementation was found\n     */\n    public UnboundMethod build() {\n      if (method != null) {\n        return method;\n      } else {\n        throw new RuntimeException(\"Cannot find method: \" + name);\n      }\n    }\n\n    /**\n     * Returns the first valid implementation as a BoundMethod or throws a RuntimeError if there is\n     * none.\n     *\n     * @param receiver an Object to receive the method invocation\n     * @return a {@link BoundMethod} with a valid implementation and receiver\n     * @throws IllegalStateException if the method is static\n     * @throws IllegalArgumentException if the receiver's class is incompatible\n     * @throws RuntimeException if no implementation was found\n     */\n    public BoundMethod build(Object receiver) {\n      return build().bind(receiver);\n    }\n\n    /**","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/common/src/main/java/org/apache/iceberg/common/DynMethods.java#L450-L486","documentation":"DynMethods.Buildable.build() throws a RuntimeException when reflective lookup found no implementation for the requested method name across the tried classes/packages. It is used for optional third-party integrations where Iceberg falls back to plain reflection because a compile-time dependency does not exist. The runtime exception signals the target class/method is absent from the runtime classpath or has an incompatible signature.","triggerScenarios":"Calling UnboundMethod builder .buildImpl(...)/.build(...) when no ctor/impl matched: class not present, method renamed in the dependency version on the classpath, or loader cannot see the class.","commonSituations":"Deploying Iceberg against a different version of a dependency (e.g. Hadoop, AWS SDK, Parquet) than the one the reflective lookup expects; fat-jar shading that strips classes; classloader isolation in app servers or Spark/Flink containers.","solutions":["Check the classpath contains the exact dependency version whose method signature the DynMethods lookup targets (mvn dependency:tree / jar tf)","Verify the method name and parameter types passed to the DynMethods builder match the target class","Print the failing lookup target from the message and inspect the jar on the runtime classpath, not the compile-time one","Switch to buildChecked() and handle NoSuchMethodException to degrade gracefully instead of failing","Exclude/relocate conflicting shaded copies of the dependency"],"exampleFix":"// before\nUnboundMethod m = DynMethods.builder(\"putToByteBuffer\").impl(UnsafeUtil.class, ByteBuffer.class, long.class, byte[].class).build();\n// after\nUnboundMethod m;\ntry {\n  m = DynMethods.builder(\"putToByteBuffer\").impl(UnsafeUtil.class, ByteBuffer.class, long.class, byte[].class).buildChecked();\n} catch (NoSuchMethodException e) {\n  m = null; // fall back to non-reflective path\n}","handlingStrategy":"try-catch","validationCode":"// Precheck reflective availability\ntry {\n  Class.forName(\"com.example.ThirdParty\").getMethod(\"target\", ParamType.class);\n} catch (ClassNotFoundException | NoSuchMethodException e) {\n  LOG.warn(\"Reflective target unavailable: {}\", e.getMessage());\n}","typeGuard":"boolean hasImpl(DynMethods.UnboundMethod.Builder b) { try { b.buildChecked(); return true; } catch (NoSuchMethodException e) { return false; } }","tryCatchPattern":"try { UnboundMethod m = builder.build(); } catch (RuntimeException e) { /* fall back to non-reflective path */ }","preventionTips":["Pin the exact dependency version the reflective lookup targets","Use buildChecked() for optional integrations","Provide multiple impl(...) candidates for different dependency versions","Watch for shaded/relocated classes in fat jars"],"tags":["reflection","classpath","runtime"],"backgroundTag":"missing-dependency","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}