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

Cannot make a static reference to the non-static type T #1781

Closed
testforstephen opened this issue May 26, 2021 · 6 comments · Fixed by #1797
Closed

Cannot make a static reference to the non-static type T #1781

testforstephen opened this issue May 26, 2021 · 6 comments · Fixed by #1797
Assignees
Milestone

Comments

@testforstephen
Copy link
Contributor

import java.util.function.Consumer;

public class HelloWorld {
    public static <T> void build(T element) {
        new Thread(() -> {
            new Consumer<T>() {

                @Override
                public void accept(T t) {

                }
            };
        });
    }
}

Opening the sample code in VS Code, it reports "Cannot make a static reference to the non-static type T" error at the line of public void accept(T t). The same code doesn't have error in Eclipse and Intellij IDEA.

@snjeza
Copy link
Contributor

snjeza commented May 28, 2021

This is an Eclipse regression issue. It can be reproduced in Eclipse 4.20M3 and Eclipse I20210526-2310.

@rgrunber
Copy link
Contributor

Thanks for narrowing this down. Also seems to have been reported recently upstream as https://bugs.eclipse.org/bugs/show_bug.cgi?id=572873 .

@rgrunber rgrunber added the bug label May 28, 2021
@testforstephen
Copy link
Contributor Author

I'm using Eclipse 2020-12. Yes, it's same as the upstream issue. If the generic method includes a lambda expression and use the generics inside the lambda expression, it will report this error.

@testforstephen
Copy link
Contributor Author

This is a regression issue introduced by 2021-03 release. And the upstream issue has been fixed and targeted for 4.20 RC2. And the I-build for 4.20 RC2 is released at June 3, see https://download.eclipse.org/eclipse/downloads/. But the release download page (https://download.eclipse.org/releases/2021-06/) didn't include RC2 yet. The release link is what we used in target platform definition.

@rgrunber Do you know what's the status of 4.20 RC2?

@snjeza
Copy link
Contributor

snjeza commented Jun 9, 2021

@rgrunber
Copy link
Contributor

rgrunber commented Jun 9, 2021

Yup, and we'll likely be able to adopt the final release final release of 2021-06 (4.20) next Wednesday : https://wiki.eclipse.org/Category:SimRel-2021-06 . We can at least use the I-build to verify.

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

Successfully merging a pull request may close this issue.

3 participants