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 doesn't work on lambdas which returns a generic type #498

Closed
gayanper opened this issue Jul 1, 2023 · 1 comment · Fixed by #499
Closed

Breakpoint doesn't work on lambdas which returns a generic type #498

gayanper opened this issue Jul 1, 2023 · 1 comment · Fixed by #499

Comments

@gayanper
Copy link
Contributor

gayanper commented Jul 1, 2023

Take the following code blocks

package com.example.demo;

import java.util.Optional;
import java.util.function.Function;

public class Test {
  public static void main(String[] args) {
    map(t -> Optional.ofNullable(t), "Null").isPresent();
  }

  private static <T, R> Optional<? extends R> map(Function<? super T, ? extends Optional<? extends R>> mapper, T value) {
    return mapper.apply(value);
  }
}
package com.example.demo;

import java.util.Optional;
import java.util.function.Function;

public class Test {
  public static void main(String[] args) {
    map(t -> Optional.ofNullable(t), "Null").isPresent();
  }

  private static <T, R> Optional<R> map(Function<T, Optional<R>> mapper, T value) {
    return mapper.apply(value);
  }
}
package com.example.demo;

import java.util.Optional;
import java.util.function.Function;

public class Test {
  public static void main(String[] args) {
    map(t -> Optional.ofNullable(t), "Null").isPresent();
  }

  private static Optional<String> map(Function<String, Optional<String>> mapper, String value) {
    return mapper.apply(value);
  }
}
Environment
  • Operating System: Any
  • JDK version: 17
  • Visual Studio Code version: 1.79.2
  • Java extension version: 1.20
  • Java Debugger extension version: 0.52
Steps To Reproduce
  1. Add inline breakpoint into t -> Optional.ofNullable(t)
  2. Run the program
Current Result

The breakpoint doesn't work

Expected Result

The execution should stop at the lambda

Additional Informations

The issue is when trying to find lambda methods from the debugger API, the method object doesn't provide the generic signature, But the signature we try to match has the generic signature which cause the match failure.

@gayanper
Copy link
Contributor Author

gayanper commented Jul 1, 2023

If I change the map method to

  private static Optional<String> map(Function<String, Optional> mapper, String value) {
    return mapper.apply(value);
  }

everything works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant