{"record":{"id":"e30253ec9a80ed77","repo":"apache/cassandra","slug":"cannot-access-method-create-in-s","errorCode":null,"errorMessage":"Cannot access method create in %s","messagePattern":"Cannot access method create in (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/compress/DefaultCompressionProvider.java","lineNumber":84,"sourceCode":"            Method method = compressorClass.getMethod(\"create\", Map.class);\n            ICompressor compressor = (ICompressor)method.invoke(null, compressionOptions);\n            // Check for unknown options\n            for (String provided : compressionOptions.keySet())\n                if (!compressor.supportedOptions().contains(provided))\n                    throw new ConfigurationException(\"Unknown compression options \" + provided);\n            return compressor;\n        }\n        catch (NoSuchMethodException e)\n        {\n            throw new ConfigurationException(\"create method not found\", e);\n        }\n        catch (SecurityException e)\n        {\n            throw new ConfigurationException(\"Access forbidden\", e);\n        }\n        catch (IllegalAccessException e)\n        {\n            throw new ConfigurationException(\"Cannot access method create in \" + compressorClass.getName(), e);\n        }\n        catch (InvocationTargetException e)\n        {\n            if (e.getTargetException() instanceof ConfigurationException)\n                throw (ConfigurationException) e.getTargetException();\n\n            Throwable cause = e.getCause() == null\n                            ? e\n                            : e.getCause();\n\n            throw new ConfigurationException(format(\"%s.create() threw an error: %s %s\",\n                                                    compressorClass.getSimpleName(),\n                                                    cause.getClass().getName(),\n                                                    cause.getMessage()),\n                                             e);\n        }\n        catch (ExceptionInInitializerError e)\n        {","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/compress/DefaultCompressionProvider.java#L66-L102","documentation":"Method.invoke on the compressor's create(Map) threw IllegalAccessException: the method exists but is not accessible from DefaultCompressionProvider (e.g. it is non-public, or its declaring class is not accessible). This is wrapped as a ConfigurationException naming the class whose create method could not be accessed.","triggerScenarios":"createCompressor() targeting a class whose create(Map) method is package-private/protected/private, or whose declaring class is non-public so even a public method is unreachable reflectively without setAccessible.","commonSituations":"Custom compressor implementations with non-public factory methods; nesting a compressor class inside another class without making it public; obfuscated/minified builds that strip public modifiers; package-private compressor classes in third-party jars.","solutions":["Make the create(Map) method (and its declaring class) public static.","Call method.setAccessible(true) in a custom provider if you control the code path and policy permits it.","Move the compressor class to a public top-level class in its own file or an exported package."],"exampleFix":"// before\nclass MyCompressor implements ICompressor { static MyCompressor create(Map<String,String> o) {...} }\n// after\npublic class MyCompressor implements ICompressor { public static ICompressor create(Map<String,String> o) {...} }","handlingStrategy":"validation","validationCode":"Method m;\ntry { m = compressorClass.getMethod(\"create\", Map.class); }\ncatch (NoSuchMethodException e) { throw new IllegalStateException(\"no create\"); }\nif (!Modifier.isPublic(m.getModifiers()) || !Modifier.isPublic(compressorClass.getModifiers()))\n    throw new IllegalStateException(\"create and its declaring class must be public\");","typeGuard":"boolean isPubliclyAccessible(Class<?> c) {\n    try { return Modifier.isPublic(c.getMethod(\"create\", Map.class).getModifiers()) && Modifier.isPublic(c.getModifiers()); }\n    catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try {\n    registry.getCompressor(cls, opts);\n} catch (ConfigurationException e) {\n    if (e.getMessage().startsWith(\"Cannot access method create\")) log.error(\"Make {}.create(Map) public\", cls);\n    throw e;\n}","preventionTips":["Declare both the compressor class and its create(Map) method public","Avoid nested/package-private compressor classes","Run checkstyle/reflection tests that verify factory accessibility","Keep custom compressors as public top-level classes"],"tags":["compression","reflection","visibility"],"backgroundTag":"permission-denied","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}