Skip to content

[Critical] Cannot debug multiline nested method expression's lambda statements #521

Description

package com.example.micrometerdemo;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.lang.reflect.Constructor;
import java.util.Arrays;

public class Snippet {
    private String name;
    

    public Snippet(@JsonProperty("name") String name) {
      this.name = name;
    }


    public final String getName() {
    Constructor<?> constructor =
        Arrays.stream(this.getClass().getDeclaredConstructors())
            .filter(
                input ->
                    input.getParameterAnnotations().length > 0
                        && input.getParameterAnnotations()[0].length > 0
                        && input.getParameterAnnotations()[0][0] instanceof JsonProperty)
            .findFirst()
            .orElseThrow(
                () ->
                    new IllegalStateException(
                        "Constructor must have a first parameter annotated with JsonProperty(\"<operator name>\")"));

    JsonProperty jsonPropertyAnnotation =
        (JsonProperty) constructor.getParameterAnnotations()[0][0];
    return jsonPropertyAnnotation.value();
  }

  public static void main(String[] args) {
    new Snippet("am").getName();
  }
}

Try to debug the

                  input.getParameterAnnotations().length > 0
                        && input.getParameterAnnotations()[0].length > 0
                        && input.getParameterAnnotations()[0][0] instanceof JsonProperty)

By adding a breakpoint at the line input.getParameterAnnotations().length > 0, when debugging is started the breakpoint is rejected. But if we try to step into filter method and then step into Predicate#test method the debugger comes into this code block and everything like evaluations works.

This works as expected by adding the line breakpoint as mentioned above in Eclipse.

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