Clean up Java 27 compatibility hack

未关闭
#1 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
冷清
技术栈
java
领域
compilers

调研方向

从 src/main/java/software/coley/sourcesolver/util/compat 开始,检查兼容性提交 05b54eb0fabf4b57702d875d808d9ea219c4283d,重点关注 JavacParser 工厂调用及其 Java 27 契约。在决定应如何处理 parser 构造之前,先审查所引用的 OpenJDK 更改;完成的标准是清理兼容性逻辑,同时不破坏 AST 范围解析。

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

描述

enhancement

Compatibility commit: 05b54eb0fabf4b57702d875d808d9ea219c4283d

Compatibility logic: https://github.com/Col-E/SourceSolver/tree/master/src/main/java/software/coley/sourcesolver/util/compat

Somehow the parser factory call didn't totally break.

// Build parser for source and extract the end-pos table so that we can resolve AST ranges
JavacParser parser = factory.newParser(source,
		false /* keepJavadoc */,
		true  /* keepEndPos */,
		false /* keepLineMap */
);

The contract is different now, but doesn't immediately cause problems.

// Build parser for source and extract the end-pos table so that we can resolve AST ranges
JavacParser parser = factory.newParser(source,
		false /* keepJavadoc */,
		true  /* keepLineMap */,
		false /* parseModuleInfo */
);

We may want to also have some compat logic for building the parser instances...


Rant

This dogshit compatibility hack exists because we don't have maven/gradle support for Java 27 yet, but people already noticed because they try and run consuming projects on bleeding edge releases... yay.

I would have liked to use multi-release jars, but oh my god this is impossible. Because we use --add-exports we cannot use --release. And guess what mutli-release support in Maven/Gradle loves to use? Yeah.

I'm sure there's a way around it but I wasted 2.5 hours on this already...


Most javac internal changes can be found here:

  • https://github.com/openjdk/jdk/pulls?q=is%3Apr+author%3Acushon
    • 31058: Clean up calls to deprecated getStartPosition and getEndPosition methods
    • 29994: Don't require a CompilationUnit for end position APIs
    • 29463: Store end positions on more trees
    • 28610: Store end positions directly in JCTree
主要语言
Java
星标
12
派生
2
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

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