microsoft / microsoft/vscode-java-debug

Extension incorrectly runs cached `.class` file from another class of same name with no `package`

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

还没有人认领这个 Issue。

ai-triaged bug
主要语言
TypeScript
星标
591
派生
429
平均合并
1 天 9 小时
30 天内合并 PR
19

描述

Bug report

Suppose there is a file structure:

folder1/
    Main.java
folder2/
    Main.java
// folder1/Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println("Main 1");
    }
}
// folder2/Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println("Main 2");
    }
}

No package statements; the projects are not connected at all.

When folder1/Main.java is run first, it gives the correct output Main 1.
But if folder2/Main.java is then run, it gives the wrong output of Main 1 instead of Main 2; the first built file is run instead.
folder1/Main.java 'shadows' folder2/Main.java, since the class name is the same and there are no package statements.
Another file structure that causes this is ./Main.java, ./folder/Main.java

This bug is inconvenient when multiple different, unrelated Java projects are in the same workspace.

贡献指南

打开贡献指南

从这里开始

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

调研方向

通过运行 folder1/Main.java,然后运行 folder2/Main.java 来重现该问题,同时包括 ./Main.java 和 ./folder/Main.java 的布局。跟踪扩展如何选择缓存的已编译类;完成的标准是每个不相关的 Main.java 都运行其自身的输出,包括在另一个文件已经运行之后。

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

评估

技术栈
java, typescript, vscode
领域
developer-experience, devtools
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 发到你的邮箱

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