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

Investigate Native-Compiling jdt.ls #13835

Closed
tsmaeder opened this issue Jul 12, 2019 · 12 comments
Closed

Investigate Native-Compiling jdt.ls #13835

tsmaeder opened this issue Jul 12, 2019 · 12 comments
Assignees
Labels
area/languages Issues related to Language extensions or plugins integration. kind/task Internal things, technical debt, and to-do tasks to be performed. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. status/analyzing An issue has been proposed and it is currently being analyzed for effort and implementation approach

Comments

@tsmaeder
Copy link
Contributor

I'd like to know how to native compile (using Graal VM) jdt.ls including the Microsoft debug extension. How does memory-consumption and performance change in the native-compiled version? How can we run it with those two VS Code extensions?

@tsmaeder tsmaeder added kind/task Internal things, technical debt, and to-do tasks to be performed. team/languages area/languages Issues related to Language extensions or plugins integration. labels Jul 12, 2019
@rhopp rhopp added the team/pm label Jul 12, 2019
@rhopp
Copy link
Contributor

rhopp commented Jul 12, 2019

This one is definitely not an endgame issue - assigning team/pm (@slemeur, @l0rd ) for correct prioritization.

@rhopp rhopp added the status/analyzing An issue has been proposed and it is currently being analyzed for effort and implementation approach label Jul 12, 2019
@tsmaeder
Copy link
Contributor Author

@rhopp of course it's not a Che 7 task.

@sunix
Copy link
Contributor

sunix commented Jul 15, 2019

I don't know how jdt.ls is packaged but I don't think it will be possible to natively compile a OSGi app.

@nickboldt nickboldt added this to the 7.x milestone Jul 15, 2019
@tolusha
Copy link
Contributor

tolusha commented Jul 16, 2019

@tsmaeder
Just to be on the same page. There are sources for jdt.ls [1] and for java-debugger [2]. The idea is to use s2i [3] tool to provide the same image as is used for the Che Plugin [4], right?

[1] https://github.com/redhat-developer/vscode-java
[2] https://github.com/Microsoft/vscode-java-debug
[3] https://github.com/openshift/source-to-image
[4] https://github.com/eclipse/che-plugin-registry/blob/master/v3/plugins/redhat/java/0.46.0/meta.yaml#L15

@tolusha tolusha self-assigned this Jul 16, 2019
@tsmaeder
Copy link
Contributor Author

@tolusha no, I just want to know if we can take the OSGI application that is jdt.ls and native-compile it with a fixed set of extension bundles. No containers involved.

@tsmaeder
Copy link
Contributor Author

I don't know how jdt.ls is packaged but I don't think it will be possible to natively compile a OSGi app.

Well, we'll never know until we try :-)

@sunix
Copy link
Contributor

sunix commented Jul 16, 2019

I don't know how jdt.ls is packaged but I don't think it will be possible to natively compile a OSGi app.

Well, we'll never know until we try :-)

Few tips: https://quarkus.io/guides/writing-native-applications-tips

@tolusha
Copy link
Contributor

tolusha commented Jul 19, 2019

For testing purpose I used osgi-mave-example [1] based on Apache Felix [2]. Despite the fact that dynamic class loading / unloading is not supposed [3] I tried to pack all classes in a single resulted file using -H:ReflectionConfigurationFiles property [4].

Here is the script to prepare Reflection configuration file. It is supposed to be run in bundle folder.

Cooking reflection configuration file

rm .classes

for f in *.jar 
do 
	jar tvf $f | sed 's/ .* //g' | grep "class" | sed 's/\//./g' | sed 's/.class//g'  > .classes
done

echo "[" > reflect.json
for c in $(cat .classes)
do
	size=$(stat --printf="%s" reflect.json)
	if (( $size > 10 )); then
	    echo "," >> reflect.json
	fi
	echo "  {" >> reflect.json
	echo "\"name\" : \"$c\"," >> reflect.json
	echo "\"allDeclaredConstructors\" : true," >> reflect.json
	echo "\"allPublicConstructors\" : true," >> reflect.json
	echo "\"allDeclaredMethods\" : true," >> reflect.json
	echo "\"allPublicMethods\" : true," >> reflect.json
	echo "\"allDeclaredClasses\" : true," >> reflect.json
	echo "\"allPublicClasses\" : true" >> reflect.json
	echo "  }" >> reflect.json
done
echo "]" >> reflect.json

rm .classes

Command to compile the felix.jar:

native-image -jar felix.jar \
     -cp ../bundle/org.apache.felix.bundlerepository-2.0.6.jar:../bundle/org.apache.felix.gogo.command-0.16.0.jar:../bundle/org.apache.felix.gogo.runtime-0.16.2.jar:../bundle/org.apache.felix.gogo.shell-0.10.0.jar:../bundle/org.apache.felix.scr-2.0.2.jar \
     -H:ReflectionConfigurationFiles=reflect.json \
     -H:+ReportUnsupportedElementsAtRuntime \
     --static --no-server 

I got the error:

Error: Error parsing reflection configuration in /home/tolusha/projects/temp/osgi-maven-example/runtime/bin/reflect.json:
Class org.apache.felix.scr.impl.ScrShellCommand not found

It is weird, because the class above exists in org.apache.felix.scr-2.0.2.jar

[1] https://github.com/thomaseizinger/osgi-maven-example
[2] https://felix.apache.org/
[3] https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md
[4] https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md#reflection

reflect.json.zip

@tsmaeder tsmaeder modified the milestones: 7.x, Backlog - Languages Sep 23, 2019
@tsmaeder tsmaeder mentioned this issue Nov 27, 2019
26 tasks
@JPinkney
Copy link
Contributor

@tsmaeder suggested that I try getting it to work using atomos (https://github.com/tjwatson/atomos) and so here's what I found:

For testing purposes I forked the atomos project [1] and added jdt.ls as a git submodule to the service.substract test folder and tried to use that to produce a native-image.

After building the atomos project with mvn clean install -Pjava8, I built jdt.ls and then copied all the jars from eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/ into atomos.tests/service.substrate/target/substrate_lib folder to see if atomos could resolve them.

Inside of the atomos.tests/service.substrate folder I ran JAVA_HOME=/usr/lib/jvm/graalvm mvn clean package I was able to produce an atomos executable. If you cd into the target folder and then run the executable called atomos you'll get a prompt. If we run atomos:list at that prompt we get a list of bundles that are resolved and active:

BUNDLES:
  org.apache.felix.gogo.runtime ACTIVE
  org.eclipse.m2e.maven.runtime ACTIVE
  org.eclipse.core.variables RESOLVED
  org.apache.felix.http.whiteboard ACTIVE
  org.eclipse.jdt.ls.core RESOLVED
  org.eclipse.jdt.compiler.apt RESOLVED
  org.eclipse.xtend.lib ACTIVE
  org.eclipse.core.jobs RESOLVED
  org.apache.felix.http.api ACTIVE
  javax.inject ACTIVE
  org.apache.ant ACTIVE
  org.eclipse.ant.core RESOLVED
  org.eclipse.core.contenttype RESOLVED
  org.eclipse.core.filebuffers RESOLVED
  org.eclipse.jdt.compiler.tool RESOLVED
  org.eclipse.core.expressions RESOLVED
  org.eclipse.text ACTIVE
  org.eclipse.equinox.simpleconfigurator.manipulator ACTIVE
  org.eclipse.core.net.win32.x86_64 INSTALLED
  org.eclipse.equinox.common RESOLVED
  org.eclipse.jdt.core RESOLVED
  org.apache.felix.webconsole ACTIVE
  org.apache.log4j ACTIVE
  org.eclipse.equinox.launcher ACTIVE
  org.hamcrest.core ACTIVE
  org.eclipse.lsp4j ACTIVE
  org.eclipse.jdt.junit.core RESOLVED
  org.eclipse.lsp4j.jsonrpc ACTIVE
  org.eclipse.debug.core RESOLVED
  org.eclipse.core.net RESOLVED
  org.eclipse.core.commands ACTIVE
  org.eclipse.jdt.launching RESOLVED
  org.eclipse.m2e.archetype.common ACTIVE
  service.impl.activator ACTIVE
  com.google.guava ACTIVE
  com.ibm.icu.base ACTIVE
  org.eclipse.osgi.util ACTIVE
  org.eclipse.jdt.junit.runtime ACTIVE
  javax.annotation-api ACTIVE
  org.eclipse.equinox.simpleconfigurator RESOLVED
  org.eclipse.equinox.security.linux.x86_64 RESOLVED
  org.eclipse.equinox.registry RESOLVED
  org.eclipse.equinox.preferences RESOLVED
  org.osgi.service.cm ACTIVE
  com.google.gson ACTIVE
  org.eclipse.jdt.debug RESOLVED
  org.eclipse.osgi ACTIVE
  org.eclipse.m2e.maven.runtime.slf4j.simple ACTIVE
  javax.xml ACTIVE
  org.eclipse.m2e.lifecyclemapping.defaults ACTIVE
  osgi.promise ACTIVE
  org.apache.felix.scr ACTIVE
  org.eclipse.buildship.core RESOLVED
  org.eclipse.compare.core RESOLVED
  org.eclipse.ltk.core.refactoring RESOLVED
  org.eclipse.equinox.security.win32.x86_64 INSTALLED
  org.osgi.service.event ACTIVE
  org.eclipse.equinox.security.macosx INSTALLED
  com.google.guava ACTIVE
  org.eclipse.m2e.maven.indexer ACTIVE
  org.eclipse.equinox.launcher.cocoa.macosx.x86_64 INSTALLED
  org.eclipse.core.runtime RESOLVED
  org.junit ACTIVE
  org.eclipse.xtend.lib.macro ACTIVE
  org.eclipse.m2e.workspace.cli ACTIVE
  org.eclipse.osgi.services ACTIVE
  service.impl ACTIVE
  org.eclipse.core.filesystem ACTIVE
  org.eclipse.equinox.app RESOLVED
  org.eclipse.equinox.security RESOLVED
  org.gradle.toolingapi ACTIVE
  org.eclipse.equinox.launcher.win32.win32.x86_64 INSTALLED
  org.eclipse.equinox.frameworkadmin.equinox ACTIVE
  org.eclipse.jdt.launching.macosx INSTALLED
  org.jboss.tools.maven.apt.core RESOLVED
  org.eclipse.jdt.apt.core RESOLVED
  org.eclipse.jdt.apt.pluggable.core RESOLVED
  org.eclipse.xtext.xbase.lib ACTIVE
  org.eclipse.core.net.linux.x86_64 RESOLVED
  org.apache.felix.http.jetty ACTIVE
  service.contract ACTIVE
  service.user ACTIVE
  org.eclipse.osgi.compatibility.state RESOLVED
  org.eclipse.jdt.core.manipulation RESOLVED
  org.eclipse.equinox.launcher.gtk.linux.x86_64 RESOLVED
  org.slf4j.api ACTIVE
  org.eclipse.core.resources RESOLVED
  org.apache.felix.http.servlet-api ACTIVE
  org.apache.felix.gogo.shell ACTIVE
  org.eclipse.equinox.frameworkadmin ACTIVE
  org.apache.felix.gogo.command ACTIVE
  org.apache.commons.lang3 ACTIVE
  org.eclipse.m2e.core RESOLVED
  org.eclipse.m2e.jdt RESOLVED

One thing to notice from that output is that things like org.eclipse.jdt.ls.core are set to resolved and not active.

If you try and start org.eclipse.jdt.ls.core manually for example, you'll receive java.lang.ClassNotFoundException: org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin cannot be found by org.eclipse.jdt.ls.core_0.49.0.201912101519

I'm not sure if something is not getting loaded correctly or why this error is appearing but that's where my investigations ended.

[1] - https://github.com/JPinkney/atomos/tree/jdt.ls-tests

@che-bot
Copy link
Contributor

che-bot commented Feb 4, 2021

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

@che-bot che-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 4, 2021
@ericwill ericwill removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 4, 2021
@ericwill ericwill added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. labels Feb 4, 2021
@che-bot
Copy link
Contributor

che-bot commented Aug 9, 2021

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

@che-bot che-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 9, 2021
@svor svor removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 17, 2021
@che-bot
Copy link
Contributor

che-bot commented Feb 13, 2022

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

@che-bot che-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 13, 2022
@che-bot che-bot closed this as completed Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/languages Issues related to Language extensions or plugins integration. kind/task Internal things, technical debt, and to-do tasks to be performed. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. status/analyzing An issue has been proposed and it is currently being analyzed for effort and implementation approach
Projects
None yet
Development

No branches or pull requests

10 participants