{"record":{"id":"a60698198cc8b08b","repo":"apache/beam","slug":"standard-logical-type-s-has-a-zero-argument-constructor-but","errorCode":null,"errorMessage":"Standard logical type '%s' has a zero-argument constructor, but it is not accessible.","messagePattern":"Standard logical type '(.+?)' has a zero-argument constructor, 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":455,"sourceCode":"                  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(\n                      \"Standard logical type '%s' does not have a zero-argument constructor.\", urn),\n                  e);\n            } catch (IllegalAccessException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Standard logical type '%s' has a zero-argument constructor, but it is not accessible.\",\n                      urn),\n                  e);\n            } catch (ReflectiveOperationException e) {\n              throw new RuntimeException(\n                  String.format(\n                      \"Error instantiating logical type '%s' with zero-argument constructor.\", urn),\n                  e);\n            }\n          }\n        }\n        // Special-case for DATETIME and DECIMAL which are logical types in portable representation,\n        // but not yet in Java. (https://github.com/apache/beam/issues/19817)\n        if (urn.equals(URN_BEAM_LOGICAL_MILLIS_INSTANT)) {\n          return FieldType.DATETIME;\n        } else if (urn.equals(URN_BEAM_LOGICAL_DECIMAL)) {\n          return FieldType.DECIMAL;","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java#L437-L473","documentation":"If the logical type class has a zero-argument constructor that is not accessible (IllegalAccessException during getConstructor().newInstance()), SchemaTranslation throws RuntimeException 'has a zero-argument constructor, but it is not accessible'.","triggerScenarios":"Decoding an argument-less logical type whose no-arg constructor is private/package-private, or whose class lives in a JPMS module that does not open its package.","commonSituations":"Singleton-style logical types with private constructors; modularized apps without --add-opens; builders used instead of public constructors.","solutions":["Make the no-arg constructor public.","With JPMS, add opens/exports for the package or pass --add-opens <module>/<package>=ALL-UNNAMED.","Register a public implementation class for the URN instead of a hidden one.","Catch the RuntimeException when decoding and surface a clear schema compatibility error."],"exampleFix":"// before\nprivate IdLogicalType(){}\n// after\npublic IdLogicalType(){}","handlingStrategy":"validation","validationCode":"java.lang.reflect.Constructor<?> c = logicalTypeClass.getConstructor();\nif (!java.lang.reflect.Modifier.isPublic(c.getModifiers())\n    || !java.lang.reflect.Modifier.isPublic(logicalTypeClass.getModifiers()))\n  throw new IllegalStateException(\"No-arg constructor not accessible\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make no-arg constructors public.","In JPMS apps, open the containing package (--add-opens or module-info opens).","Avoid singleton private constructors on logical types registered by URN.","Verify reflective instantiation in unit tests."],"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"}