java generator: object flags produce uncompilable code

未关闭 适合新手
#296 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@slukes 已经在做这个了。

开始于 2026年11月6日。

  • #297 来自 @slukes —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
77/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go, java
领域
backend, cli

调研方向

阅读 internal/generators/java/java.tmpl 和 internal/generators/java/java.go 中 ToMapLiteral 的实现;issue 指出了出错的模板调用和生成的 Java 代码。检查其他 Java 生成器类型如何处理导入、返回类型和对象默认值。完成标准是:生成的对象访问器使用 Value 默认值和返回类型,包含所需的导入,并能通过 SDK 编译。

由索引模型根据 Issue 内容生成。

描述

Version: openfeature CLI 0.4.1 (openfeature generate java); the templates on main (7f79478) are unchanged.

Manifest:

{"flags":{"retry_policy":{"flagType":"object","defaultValue":{"backoff_seconds":2,"max_attempts":3}}}}

Generated:

public Object retryPolicy(EvaluationContext ctx) {
    return client.getObjectValue("retry_policy", Map.of("backoff_seconds", 2, "max_attempts", 3), ctx);
}

Problems

  1. java.util.Map is not imported (internal/generators/java/java.tmpl lines 4-7 only import the OpenFeature SDK types), so javac fails with cannot find symbol: variable Map.
  2. Even with the import, Client.getObjectValue(String, Value, EvaluationContext) takes a dev.openfeature.sdk.Value, not a Map. The template (lines 59 and 64) passes the ToMapLiteral output from java.go (toMapLiteral, line 59-68, which writes Map.of() directly. The accessors also return Object instead of Value.

Expected: an import plus a Value-typed default (e.g. Value.objectToValue(Map.of(...))) and Value return types.

Related: #248 (typesafe object flags).

主要语言
Go
星标
67
派生
25
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

open-feature/cli 的其他 Issue

查看 open-feature/cli 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。