microsoft / microsoft/vscode-java-debug

Logpoints can't be evaluated

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

还没有人认领这个 Issue。

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

描述

When adding logpoints to sun.awt.X11.XDragSourcePeer, I often get errors.

Environment
  • Operating System: Ubuntu 22.04.4 LTS
  • JDK version: OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
  • Visual Studio Code version: 1.91.1
  • Java extension version: v1.32.0
  • Java Debugger extension version: v0.58.0
Steps To Reproduce
  1. Use attached source file
  2. Extract jdk src.zip and add to classpath (I forget how I did this)
  3. Open "Java Projects" > java.desktop > sun.awt.X11 > XDragSourceContextPeer, add "Hello world" logpoint to line 483 (which is doUpdateTargetWindow(subwindow, time);.
  4. Get error [Logpoint] Log message 'Hello world' error: Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or block of well-formed statements
  5. Observe > [Warn - 3:19:18 PM] Jul 23, 2024, 3:19:18 PM Compile error during code evaluation: sun.awt.X11.XMotionEvent cannot be resolved to a type in the Language Support for Java log.

Sample program:

import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.awt.event.*;
import java.util.logging.ConsoleHandler;

import java.util.logging.Level;
import java.util.logging.Logger;

public class DragAndDropExample extends JFrame {

    public DragAndDropExample() {
        setTitle("Drag and Drop Example");
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);

        JTextArea sourceTextArea = new JTextArea("Drag this text");
        sourceTextArea.setDragEnabled(true);
        sourceTextArea.setLineWrap(true);
        sourceTextArea.setWrapStyleWord(true);
        JScrollPane sourceScrollPane = new JScrollPane(sourceTextArea);

        JTextArea targetTextArea = new JTextArea("Drop here");
        targetTextArea.setLineWrap(true);
        targetTextArea.setWrapStyleWord(true);
        JScrollPane targetScrollPane = new JScrollPane(targetTextArea);

        new DropTarget(targetTextArea, new DropTargetListener() {
            @Override
            public void dragEnter(DropTargetDragEvent dtde) {
                if (dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                    dtde.acceptDrag(DnDConstants.ACTION_COPY);
                    System.out.println("Drag Enter: Data flavor supported");
                } else {
                    dtde.rejectDrag();
                    System.out.println("Drag Enter: Data flavor not supported");
                }
            }

            @Override
            public void dragOver(DropTargetDragEvent dtde) {
                // No action needed here
            }

            @Override
            public void dropActionChanged(DropTargetDragEvent dtde) {
                // No action needed here
            }

            @Override
            public void dragExit(DropTargetEvent dte) {
                System.out.println("Drag Exit");
            }

            @Override
            public void drop(DropTargetDropEvent dtde) {
                try {
                    if (dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                        dtde.acceptDrop(DnDConstants.ACTION_COPY);
                        String droppedText = (String) dtde.getTransferable().getTransferData(DataFlavor.stringFlavor);
                        targetTextArea.append(droppedText);
                        dtde.dropComplete(true);
                        System.out.println("Drop: Success");
                    } else {
                        dtde.rejectDrop();
                        System.out.println("Drop: Data flavor not supported");
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                    dtde.dropComplete(false);
                    System.out.println("Drop: Exception occurred");
                }
            }
        });

        setLayout(new GridLayout(2, 1));
        add(sourceScrollPane);
        add(targetScrollPane);
    }

    public static void main(String[] args) {

        Logger platformLogger = Logger.getLogger("sun.awt.X11.xembed.xdnd.XDnDDropSourceProtocol");
        platformLogger.setLevel(Level.ALL);
        
        ConsoleHandler consoleHandler = new ConsoleHandler();
        consoleHandler.setLevel(Level.ALL);
        platformLogger.addHandler(consoleHandler);

        SwingUtilities.invokeLater(() -> {
            new DragAndDropExample().setVisible(true);
        });
    }
}

Language support for Java logs:

Jul 23, 2024 3:18:58 PM org.apache.aries.spifly.BaseActivator log
INFO: Registered provider ch.qos.logback.classic.servlet.LogbackServletContainerInitializer of service jakarta.servlet.ServletContainerInitializer in bundle ch.qos.logback.classic
Jul 23, 2024 3:18:58 PM org.apache.aries.spifly.BaseActivator log
INFO: Registered provider ch.qos.logback.classic.spi.LogbackServiceProvider of service org.slf4j.spi.SLF4JServiceProvider in bundle ch.qos.logback.classic
Jul 23, 2024 3:19:01 PM com.microsoft.java.debug.plugin.internal.JavaDebuggerServerPlugin start
INFO: Starting com.microsoft.java.debug.plugin
Jul 23, 2024 3:19:13 PM com.microsoft.java.debug.core.UsageDataSession recordInfo
INFO: launch debug info
Jul 23, 2024 3:19:14 PM com.microsoft.java.debug.core.UsageDataSession recordResponse
WARNING: abnormal response
[Warn  - 3:19:18 PM] Jul 23, 2024, 3:19:18 PM Compile error during code evaluation: sun.awt.X11.XMotionEvent cannot be resolved to a type
[Error - 3:19:18 PM] Jul 23, 2024, 3:19:18 PM [Logpoint]: Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements.
Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements.
com.microsoft.java.debug.core.DebugException: Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements.
	at com.microsoft.java.debug.core.adapter.AdapterUtils.createUserErrorDebugException(AdapterUtils.java:274)
	at com.microsoft.java.debug.plugin.internal.eval.JdtEvaluationProvider.evaluate(JdtEvaluationProvider.java:176)
	at com.microsoft.java.debug.plugin.internal.eval.JdtEvaluationProvider.evaluateForBreakpoint(JdtEvaluationProvider.java:108)
	at com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler.lambda$registerBreakpointHandler$7(SetBreakpointsRequestHandler.java:206)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

Jul 23, 2024 3:19:18 PM com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler handleEvaluationResult
SEVERE: [Logpoint]: Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements.
com.microsoft.java.debug.core.DebugException: Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements.
	at com.microsoft.java.debug.core.adapter.AdapterUtils.createUserErrorDebugException(AdapterUtils.java:274)
	at com.microsoft.java.debug.plugin.internal.eval.JdtEvaluationProvider.evaluate(JdtEvaluationProvider.java:176)
	at com.microsoft.java.debug.plugin.internal.eval.JdtEvaluationProvider.evaluateForBreakpoint(JdtEvaluationProvider.java:108)
	at com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler.lambda$registerBreakpointHandler$7(SetBreakpointsRequestHandler.java:206)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Current Result

Error message is shown instead of log messages.

Expected Result

Log messages are logged.

Additional Informations

This seems to be the relevant error:

[Warn - 3:19:18 PM] Jul 23, 2024, 3:19:18 PM Compile error during code evaluation: sun.awt.X11.XMotionEvent cannot be resolved to a type

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先跟踪 JdtEvaluationProvider.evaluateForBreakpoint 以及堆栈跟踪中显示的 SetBreakpointsRequestHandler 路径。在 sun.awt.X11.XDragSourcePeer 上复现该 logpoint,并调查为什么评估报告 sun.awt.X11.XMotionEvent 无法解析。完成的标准是同一个 logpoint 在没有编译错误的情况下输出其消息。

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

评估

技术栈
java, typescript, vscode
领域
devtools
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

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