Skip to content

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

Description

@gayanper

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions