question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Go to definition doesn't compute/find results on methods inside an anonymous class

See original GitHub issue

I first thought this is a more generic regression caused by https://github.com/eclipse/eclipse.jdt.ls/pull/1807 but it turns it already happened before.

Eclipse.jdt.ls version: Tested both with latest master (https://github.com/eclipse/eclipse.jdt.ls/commit/6f7d39ae3d1481f7873d7a27ef022af8a2599e60) and (https://github.com/eclipse/eclipse.jdt.ls/commit/3121ad987dc3d9178af4b569c5c44adbfe02abd0) JDK: OpenJDK 16.0.1+9

An example:

public class App {

    public void test() {
        foo();
    }

    public String getGreeting() {
      return "foo";
    }

    public static void main(String[] args) {
        // Here go to definition on `getGreeting` works
        System.out.println(new App().getGreeting());
        Function<Integer, Integer> foo = new Function<>() {

          @Override
          public Integer apply(Integer t) {
              // Go to definition on `getGreeting` doesn't work
              new App().getGreeting();
              return 10;
          }
        };
    }
}

Also visible here:

https://user-images.githubusercontent.com/38700/124632820-f573fa00-de84-11eb-9d52-a6dfc7196406.mp4

(Code in question would be available here: https://github.com/crate/crate/blob/573bd2feb9052f9a83c01bd36cfb3c7485d0e9d3/server/src/main/java/io/crate/planner/operators/InsertFromValues.java#L653-L700)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
snjezacommented, Sep 21, 2021
1reaction
rgrunbercommented, Aug 6, 2021

Looks like the change proposed by @snjeza was recently merged upstream for this. We should expect I20210806-1800 (not yet built) to contain the fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overriding an anonymous class's methods in Java
With the above example, I wanted to understand whether we can override an anonymous class's methods or not?. Again, the main motive is...
Read more >
Anonymous Inner Class in Java - GeeksforGeeks
An anonymous class cannot access local variables in its enclosing ... Anonymous Inner class that defines inside method/constructor argument.
Read more >
Anonymous method in C# - TutorialsTeacher
This tutorial explains anonymous methods in C#. As the name suggests, an anonymous method is a method without a name. Anonymous methods can...
Read more >
Anonymous Classes - Java™ Tutorials
An anonymous class cannot access local variables in its enclosing scope that are not declared as final or effectively final. Like a nested...
Read more >
Writing Classes and Javadoc
All we must do is place these other method definitions inside the class, ... if the method itself doesn't have one, Java goes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found