microsoft / microsoft/vscode-java-debug

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

Đang mở
#1,587 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

ai-triaged bug
Ngôn ngữ chính
TypeScript
Star
591
Fork
429
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
19

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện vấn đề bằng cách chạy folder1/Main.java rồi folder2/Main.java, bao gồm cả bố cục ./Main.java và ./folder/Main.java. Theo dõi cách extension chọn các lớp đã biên dịch được lưu trong bộ nhớ đệm; được xem là hoàn tất khi mỗi Main.java không liên quan chạy đầu ra riêng của nó, kể cả sau khi tệp còn lại đã được chạy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java, typescript, vscode
Lĩnh vực
developer-experience, devtools
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.