{"record":{"id":"f6a642c13a35405d","repo":"pagehelper-org/Mybatis-PageHelper","slug":"get-the-providersqlsource-property-value-of-provid","errorCode":null,"errorMessage":"Get the ProviderSqlSource property value of providerMethodArgumentNames: ${e}","messagePattern":"Get the ProviderSqlSource property value of providerMethodArgumentNames: (.+?)","errorType":"exception","errorClass":"PageException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/github/pagehelper/util/ExecutorUtil.java","lineNumber":92,"sourceCode":"    public static Map<String, Object> getAdditionalParameter(BoundSql boundSql) {\n        try {\n            return (Map<String, Object>) additionalParametersField.get(boundSql);\n        } catch (IllegalAccessException e) {\n            throw new PageException(\"Failed to get the BoundSql property additionalParameters: \" + e, e);\n        }\n    }\n\n    /**\n     * 获取 ProviderSqlSource 属性值 providerMethodArgumentNames\n     *\n     * @param providerSqlSource\n     * @return\n     */\n    public static String[] getProviderMethodArgumentNames(ProviderSqlSource providerSqlSource) {\n        try {\n            return providerMethodArgumentNamesField != null ? (String[]) providerMethodArgumentNamesField.get(providerSqlSource) : null;\n        } catch (IllegalAccessException e) {\n            throw new PageException(\"Get the ProviderSqlSource property value of providerMethodArgumentNames: \" + e, e);\n        }\n    }\n\n    /**\n     * 尝试获取已经存在的在 MS，提供对手写count和page的支持\n     *\n     * @param configuration\n     * @param msId\n     * @return\n     */\n    public static MappedStatement getExistedMappedStatement(Configuration configuration, String msId) {\n        MappedStatement mappedStatement = null;\n        try {\n            mappedStatement = configuration.getMappedStatement(msId, false);\n        } catch (Throwable t) {\n            //ignore\n        }\n        return mappedStatement;","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/pagehelper-org/Mybatis-PageHelper/blob/c692616c5bc95b41aa779b502f991825c8e5acbc/src/main/java/com/github/pagehelper/util/ExecutorUtil.java#L74-L110","documentation":"ExecutorUtil reflectively reads ProviderSqlSource.providerMethodArgumentNames to support @SelectProvider methods; the field only exists in some mybatis versions (absence is tolerated at init). If the field exists but Field.get fails with IllegalAccessException (accessibility revoked, module restrictions, SecurityManager), the helper throws this PageException.","triggerScenarios":"Paginating a mapper method whose SQL comes from @SelectProvider (ProviderSqlSource) in an environment where the reflected field is not accessible: JPMS strong encapsulation, SecurityManager denying suppressAccessChecks, or a shaded/repackaged mybatis where setAccessible silently did not apply.","commonSituations":"Annotation-based mappers using provider classes on JDK 16+ with module encapsulation; enterprise app servers with strict security policies; mixed mybatis versions after dependency conflicts.","solutions":["Upgrade pagehelper to a release matching your mybatis version so the reflection path (or its replacement API) works","Add JVM opens for the mybatis package: --add-opens org.mybatis/java.org.apache.ibatis.builder.annotation=ALL-UNNAMED","Adjust the SecurityManager policy to grant ReflectPermission(\"suppressAccessChecks\") to the application","Replace the @SelectProvider usage with XML or annotation SQL if compatibility cannot be fixed, avoiding this code path","Deduplicate mybatis on the classpath (dependency:tree) so the standard class is loaded"],"exampleFix":"// before (JVM args)\njava -jar app.jar\n\n// after\njava --add-opens org.mybatis/java.org.apache.ibatis.builder.annotation=ALL-UNNAMED -jar app.jar","handlingStrategy":"try-catch","validationCode":"// Probe accessibility of the provider field before using @SelectProvider + pagination\njava.lang.reflect.Field f = null;\ntry {\n    f = org.apache.ibatis.builder.annotation.ProviderSqlSource.class.getDeclaredField(\"providerMethodArgumentNames\");\n    f.setAccessible(true);\n    f.get(null);\n} catch (NoSuchFieldException ignore) {\n    // tolerated: mybatis version without this field\n} catch (Throwable t) {\n    throw new IllegalStateException(\"Cannot access ProviderSqlSource internals: \" + t, t);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return mapper.selectPaged(params);\n} catch (PageException e) {\n    if (e.getMessage().contains(\"providerMethodArgumentNames\")) {\n        throw new IllegalStateException(\"Open mybatis module packages or upgrade pagehelper/mybatis\", e);\n    }\n    throw e;\n}","preventionTips":["Keep pagehelper and mybatis versions matched to the compatibility matrix","Add --add-opens for org.apache.ibatis.builder.annotation on modern JDKs","Prefer XML/annotation SQL over @SelectProvider where reflection restrictions exist","Grant ReflectPermission in app-server security policies that sandbox the application"],"tags":["reflection","mybatis","access-modifier","security","sql-provider"],"backgroundTag":"permission-denied","analyzedSha":"c692616c5bc95b41aa779b502f991825c8e5acbc","analyzedAt":"2026-09-08T03:50:49.192Z","contentChangedAt":"2026-09-08T03:50:49.192Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}