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

"Problem" The method methodName(ParamType) in the type ClassName is not applicable for the arguments () in lightweight syntax only mode #1931

Closed
StrangeNoises opened this issue May 6, 2021 · 1 comment · Fixed by eclipse-jdtls/eclipse.jdt.ls#1792
Assignees
Labels
Milestone

Comments

@StrangeNoises
Copy link

I'm running in lightweight/syntax only mode. At least, I'm trying to but the error is making me wonder.

If I write a class which extends a class that's not known to vscode-java (remember, I'm trying to run in standalone mode!) and I write another method in that class of the same name but different parameters (so not overriding the superclass method) as a method in the superclass, and elsewhere try to invoke the superclass method, I get a Problem, saying the method is not applicable for the arguments.

eg: In a completely standalone window, outside of any project, open a new Java source file with this:

public abstract class TestSyntax extends groovy.lang.Script {
    public Object run(String parameter) {
        return run();
    }
}

The problem reported is:

The method run(String) in the type TestSyntax is not applicable for the arguments ()

Screenshot 2021-05-06 at 14 41 30

The bug is that it's reporting this class of error at all. Obviously groovy.lang.Script is not available, so if I did nothing to make it available it wouldn't compile. But if vscode-java is in syntax/lightweight mode, it should only be reporting on any syntax errors, not on the failure to resolve this method.

There seems to be no option to suppress this obviously bogus message.

(The real-world situation is a gradle project which does depend on Groovy, and which builds just fine thank-you. But I've had no luck trying to get vscode-java to actually import even the simplest gradle project, so I've disabled, as far as I can determine, any attempt for it to do so. I just want syntax checking and a symbol browser for the class I'm in. But in the real case I am indeed writing a base class for scripts, which extends groovy.lang.Script, and so has a real similarity to what's happening here.)

Environment
  • Operating System: Mac OS Big Sur (intel)
  • JDK version: 16.0.1
  • Visual Studio Code version: 1.56.0
  • Java extension version: 0.79.1
Steps To Reproduce
  1. Open a new Code window
  2. Paste the above java source
  3. Save it as TestSyntax.java so it knows it's a java file
  4. The Problem will appear as a 1 next to the X in the bottom left. click on it to open and see

The entire extension log:

{
  message: 'Starting Java server with: /Library/Java/JavaVirtualMachines/adoptopenjdk-16.jdk/Contents/Home/bin/java --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dfile.encoding=utf8 -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m -jar /Users/rachel/.vscode/extensions/redhat.java-0.79.1/server/plugins/org.eclipse.equinox.launcher_1.6.100.v20201223-0822.jar -configuration /Users/rachel/Library/Application Support/Code/User/globalStorage/redhat.java/0.79.1/config_ss_mac -data /var/folders/1z/fbxgv5hx75dbs5ycdvtwgp840000gp/T/vscodesws_e0a40/ss_ws',
  level: 'info',
  timestamp: '2021-05-06 14:55:04.997'
}
{
  message: 'WARNING: Using incubator modules: jdk.incubator.foreign, jdk.incubator.vector\n',
  level: 'info',
  timestamp: '2021-05-06 14:55:05.064'
}

(I've done nothing to enable those incubator modules.)

If I try to load the java language server log I get an error saying there isn't one.

Current Result

Spurious error from incorrectly trying to resolve an out-of-classpath superclass method when in lightweight mode

The particular problem only occurs because there is another method of the same name (but different parameters) declared in the class. If I rename that eg: to runt(String parameter), the Problem disappears.

Expected Result

No errors relating to failing to resolve symbols when in lightweight syntax-only mode.

I mean, it could maybe do what it's doing if it's not extending unknown classes, because then the method call probably would be wrong. But if there's an extends or implements of any class or interface that isn't known to the language server's classloader, and it's in lightweight non-project mode and supposed to only be reporting syntax errors then it should presume that any such "missing" methods are there somewhere and let it pass.

Additional Informations

My main reason for thinking I'm in Lightweight mode is that I have an option to switch to Standard mode.

If I do that the above error doesn't go away, but I also get:

"TestSyntax.java is a non-project file, only syntax errors are reported"

Despite that clearly not being the case. But of course the real problem here seems to be that the "not applicable" error is incorrectly being thought of as a syntax error and being reported in a non-project file.

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

Successfully merging a pull request may close this issue.

4 participants