eclim icon indicating copy to clipboard operation
eclim copied to clipboard

:JavaSearchContext never works

Open isheff opened this issue 6 years ago • 3 comments

If, for instance, my cursor is on the S in System.out.println("Hello World"); in a basic demo file, and I run :JavaSearchContext, I get:

java.lang.RuntimeException: java.lang.IllegalArgumentException: File 'jar:file:///usr/lib/jvm/java-10-oracle/lib/jrt-fs.jar!java/lang/System.class' not found.
while executing command (port: 9091): -editor vim -command java_search -n "test-project" -f "src/main/java/com/isaacsheff/test/App.java" -o 154 -e utf-8 -l 6
Press ENTER or type command to continue

An analogous error appears for anything else in the standard libraries.

This is with Oracle JDK 10 on Ubuntu 18.04.

isheff avatar Jun 06 '18 22:06 isheff

Can you run the command again, but with verbose?

:verbose JavaSearchContext

That should print the full stack trace which you can then post here.

ervandew avatar Jun 07 '18 15:06 ervandew

:verbose JavaSearchContext results in:

java.lang.RuntimeException: java.lang.IllegalArgumentException: File 'jar:file:///usr/lib/jvm/java-10-oracle/lib/jrt-fs.jar!java/lang/System.class' not found.
^Iat org.eclim.util.file.FileOffsets.compile(FileOffsets.java:69)
^Iat org.eclim.util.file.FileUtils.offsetToLineColumn(FileUtils.java:125)
^Iat org.eclim.util.file.Position.fromOffset(Position.java:71)
^Iat org.eclim.plugin.jdt.command.search.SearchCommand.createPosition(SearchCommand.java:540)
^Iat org.eclim.plugin.jdt.command.search.SearchCommand.execute(SearchCommand.java:154)
^Iat org.eclim.command.Main$1.run(Main.java:100)
^Iat org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
^Iat org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
^Iat org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4577)
^Iat org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4186)
^Iat org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
^Iat org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
^Iat org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039)
^Iat org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
^Iat org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
^Iat org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
^Iat org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
^Iat org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
^Iat org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
^Iat org.eclim.eclipse.EclimApplication.start(EclimApplication.java:128)
^Iat org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
^Iat org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
^Iat org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
^Iat org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
^Iat org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
^Iat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
^Iat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
^Iat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
^Iat java.base/java.lang.reflect.Method.invoke(Method.java:564)
^Iat org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
^Iat org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
^Iat org.eclipse.equinox.launcher.Main.run(Main.java:1499)
^Iat org.eclipse.equinox.launcher.Main.main(Main.java:1472)
Caused by: java.lang.IllegalArgumentException: File 'jar:file:///usr/lib/jvm/java-10-oracle/lib/jrt-fs.jar!java/lang/System.class' not found.
^Iat org.eclim.util.file.FileOffsets.compile(FileOffsets.java:65)
^I... 32 more
while executing command (port: 9091): -editor vim -command java_search -n "test-project" -f "src/main/java/com/isaacsheff/test/App.java" -o 154 -e utf-8 -l 6 
Press ENTER or type command to continue

isheff avatar Jun 07 '18 21:06 isheff

I'm having the same issue for any built in types (e.g. Thread, AtomicBoolean etc).

Here's an output from :verbose JavaSearchContext when standing on currentThread of `Thread.currentThread()

java.lang.RuntimeException: java.lang.IllegalArgumentException: File 'jar:file:///Library/Java/JavaVirtualMachines/zulu-10.3+5.jdk/Contents/Home/lib/jrt-fs.jar!java/lang/Thread.class' not found.
^Iat org.eclim.util.file.FileOffsets.compile(FileOffsets.java:69)
^Iat org.eclim.util.file.FileUtils.offsetToLineColumn(FileUtils.java:125)
^Iat org.eclim.util.file.Position.fromOffset(Position.java:71)
^Iat org.eclim.plugin.jdt.command.search.SearchCommand.createPosition(SearchCommand.java:540)
^Iat org.eclim.plugin.jdt.command.search.SearchCommand.execute(SearchCommand.java:154)
^Iat org.eclim.command.Main$1.run(Main.java:100)
^Iat org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
^Iat org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185)
^Iat org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4095)
^Iat org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3762)
^Iat org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173)
^Iat org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
^Iat org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
^Iat org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
^Iat org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:636)
^Iat org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
^Iat org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:563)
^Iat org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:151)
^Iat org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:155)
^Iat org.eclim.eclipse.EclimApplication.start(EclimApplication.java:128)
^Iat org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
^Iat org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
^Iat org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
^Iat org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
^Iat org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
^Iat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
^Iat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
^Iat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
^Iat java.lang.reflect.Method.invoke(Method.java:498)
^Iat org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
^Iat org.eclipse.equinox.launcher.Main.basicRun(Main.java:595)
^Iat org.eclipse.equinox.launcher.Main.run(Main.java:1501)
^Iat org.eclipse.equinox.launcher.Main.main(Main.java:1474)
Caused by: java.lang.IllegalArgumentException: File 'jar:file:///Library/Java/JavaVirtualMachines/zulu-10.3+5.jdk/Contents/Home/lib/jrt-fs.jar!java/lang/Thread.class' not found.
^Iat org.eclim.util.file.FileOffsets.compile(FileOffsets.java:65)
^I... 32 more
while executing command (port: 9091): -editor vim -command java_search -n "ingest-pipeline-conductor" -f "src/main/java/com/storytel/ingestpipelineconductor/Program.java" -o 1096 -e utf-8 -l 13

It's obvious that it pulls up the file /Library/Java/JavaVirtualMachines/zulu-10.3+5. jdk/Contents/Home/lib/jrt-fs.jar and tries to get java/lang/Thread.class from that. It doesn't exist there though. That jar only has a handful classes (~66) from jdk/internal/jimage and jdk/internal/jrtfs.

Note: This works on a project using java8, so I think it's because of the changed structure layout of the JDK (since Java9) causing this.

Note2: In a Java10 project, the :JavaSearchContext command works fine for anything not in the JDK (i.e. dependencies and local classes all work).

noseglid avatar Jan 05 '19 15:01 noseglid