{"record":{"id":"4d12adcc1562988e","repo":"apache/beam","slug":"standard-logical-type-s-has-an-of-s-method-but-it-is-not","errorCode":null,"errorMessage":"Standard logical type '%s' has an of('%s') method, but it is not accessible.","messagePattern":"Standard logical type '(.+?)' has an of\\('(.+?)'\\) method, but it is not accessible\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java","lineNumber":433,"sourceCode":"              // argument is Map\n              clazz = Map.class;\n            } else if (fieldValue instanceof Row) {\n              // argument is Row\n              clazz = Row.class;\n            }\n            String objectName = clazz.getName();\n            try {\n              return FieldType.logicalType(\n                  logicalTypeClass.cast(\n                      logicalTypeClass.getMethod(\"of\", clazz).invoke(null, fieldValue)));\n            } catch (NoSuchMethodException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Standard logical type '%s' does not have a static of('%s') method.\",\n                      urn, objectName),\n                  e);\n            } catch (IllegalAccessException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Standard logical type '%s' has an of('%s') method, but it is not accessible.\",\n                      urn, objectName),\n                  e);\n            } catch (InvocationTargetException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Error instantiating logical type '%s' with of('%s') method.\",\n                      urn, objectName),\n                  e);\n            }\n          } else {\n            // Logical type without argument. Construct from constructor without parameter\n            try {\n              return FieldType.logicalType(logicalTypeClass.getConstructor().newInstance());\n            } catch (NoSuchMethodException e) {\n              throw new RuntimeException(\n                  String.format(","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java#L415-L451","documentation":"After finding a static of(%) method via reflection, the invocation may fail with IllegalAccessException; SchemaTranslation rethrows it as RuntimeException stating the of(...) method is not accessible. This happens when the method is non-public or in a non-exported package (JPMS).","triggerScenarios":"Decoding a logical type whose of() method is package-private/private, or whose class is in a module that does not export/opens the package to beam-sdks-java-core.","commonSituations":"JPMS modularized applications without --add-opens; logical type declared inside a non-public class; Kotlin/Scala factory methods with restricted visibility.","solutions":["Make the of() method public (and its enclosing class public).","With JPMS, add opens/exports of the package or run with --add-opens <module>/<package>=ALL-UNNAMED.","Avoid nested private classes for logical types; move to a top-level public class.","Catch the RuntimeException at decode time and surface a clear configuration error."],"exampleFix":"// before\nprivate static MyLogicalType of(String v){...}\n// after\npublic static MyLogicalType of(String v){...}","handlingStrategy":"validation","validationCode":"java.lang.reflect.Method m = logicalTypeClass.getMethod(\"of\", argClass);\nif (!java.lang.reflect.Modifier.isPublic(m.getModifiers())\n    || !java.lang.reflect.Modifier.isPublic(logicalTypeClass.getModifiers()))\n  throw new IllegalStateException(\"of() not accessible\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare logical type classes and of() as public top-level members.","In JPMS apps, opens the logical-type packages to beam-core.","Avoid private nested classes for logical types.","Run reflective decode in a test environment matching production module settings."],"tags":["java","apache-beam","reflection","access-modifier"],"backgroundTag":"reflection-access-denied","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}