Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakpoint with inline lambdas work only with last one #1410

Closed
jvalkeal opened this issue Nov 13, 2023 · 1 comment · Fixed by microsoft/java-debug#522
Closed

Breakpoint with inline lambdas work only with last one #1410

jvalkeal opened this issue Nov 13, 2023 · 1 comment · Fixed by microsoft/java-debug#522
Assignees

Comments

@jvalkeal
Copy link

Having a method taking multiple lambdas(i.e. just good ol' java Consumer) and calling those with inline lambdas a breakpoint only works on a last one. Taking lambda out or using null makes breakpoints to work.

Environment
  • Operating System: Linux (ubuntu 18.04)
  • JDK version: 17
  • Visual Studio Code version: 1.82.2
  • Java extension version: 1.24.0
  • Java Debugger extension version: 0.55.0
Steps To Reproduce

Copy this test class and add breakpoints to println calls and testMethod* calls.

package com.example.demo;

import java.util.function.Consumer;

import org.junit.jupiter.api.Test;

class BreakpointTests {

	static void testMethod1(Consumer<String> consumer1, Consumer<String> consumer2) {
		if (consumer1 != null) {
			consumer1.accept("hi");
		}
		if (consumer2 != null) {
			consumer2.accept("hi");
		}
	}

	@Test
	void test1() {
		testMethod1(
			s1 -> {
				// breakpoint doesn't work
				// shows "unverified breakpoint"
				System.out.println("hi");
			},
			s2 -> {
				// breakpoint works
				System.out.println("hi");
			}
		);
	}

	@Test
	void test2() {
		testMethod1(
			s1 -> {
				// breakpoint works
				System.out.println("hi");
			},
			null
		);
	}

	@Test
	void test3() {
		Consumer<String> consumer2 = s -> {
			// breakpoint works
			System.out.println("hi");
		};
		testMethod1(
			s1 -> {
				// breakpoint works
				System.out.println("hi");
			},
			consumer2
		);
	}

	static void testMethod2(Consumer<String> consumer1, Consumer<String> consumer2, Consumer<String> consumer3) {
		if (consumer1 != null) {
			consumer1.accept("hi");
		}
		if (consumer2 != null) {
			consumer2.accept("hi");
		}
		if (consumer3 != null) {
			consumer3.accept("hi");
		}
	}

	@Test
	void test4() {
		testMethod2(
			s1 -> {
				// breakpoint doesn't work
				// shows "unverified breakpoint"
				System.out.println("hi");
			},
			s2 -> {
				// breakpoint doesn't work
				// shows "unverified breakpoint"
				System.out.println("hi");
			},
			s3 -> {
				// breakpoint works
				System.out.println("hi");
			}
		);
	}

}

@testforstephen
Copy link
Contributor

I can reproduce it, it's a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment