Hi Jan,

very thanks for your detailed answer - this really helps a  lot.

It sounds plausible for me that the origin of the problem has to do with the 
interaction of the classloaders and especially thanks for the hint to the 
possibility to hide packages from the classpath. If I understand that correct 
it allows only to hide packages overlapping those in the JRE and maybe the 
origin of my probleme comes from other packages.

My idea of starting the GraalVM-LSP inside the Netbeans-IDE was that I thought 
it can be more efficient to have directly communicattion with it rather than 
communicating by a Socket. 

But on the other side, maybe it is more robust to start the LSP in its own VM.

So I will follow now this way now. 

best regards
Oliver


> Hello Oliver,
> 
> I suspect the problem here is interaction between ClassLoaders - same-named
> classes are loaded by two or more ClassLoaders, and their Class objects are
> different, and unrelated.
> 
> E.g. a class named "C" load from your module's ClassLoader may extend a
> class named "B" from your module's ClassLoader, but if some other
> ClassLoader also load class named "B", "C" is only extending "B" from your
> ClassLoader, not "B" from the other ClassLoader.
> 
> Sadly, it is really difficult to guess what exactly is going on without
> proper understanding of what exactly you are trying to achieve/some
> debugging.
> 
> I'll list two ideas below, but I would not recommend attempting either of
> them without a good understanding of what is happening. But I think the
> first question is: given that what you have is an LSP server, why run the
> server in the same JVM as the IDE? It should be easy to run the LSP in a
> separate process, which works (based on your report). Things like code
> completion or navigator should then work using the LSP connection.
> 
> The two ideas (but before attempting either of these I would recommend to
> gain a good understanding what exactly is happening w.r.t. class loading)
> are:
> - you might also be able to filter out packages from the parent
> classloaders using 'OpenIDE-Module-Hide-Classpath-Packages:' in the
> manifest:
> https://bits.netbeans.org/dev/javadoc/org-openide-modules/apichanges.html#Op
> enIDE-Module-Hide-Classpath-Packages
> https://github.com/apache/netbeans/blob/7d89336259b840ce53709cbc8240c88e32f
> d6ea1/ide/libs.truffleapi/manifest.mf#L7 but this is tricky
> - you might be able to set up a custom ClassLoader, and load what you need,
> and filter out everything you don't want, but that's quite tricky as well.
> 
> Jan
> 
> On Wed, Nov 6, 2024 at 12:10 PM Oliver Rettig <oliver.ret...@orat.de> wrote:
> > Hi,
> > 
> > I want to start the GraalVM Language-Server as a Netbeans-Plugin and I run
> > into dependency-problems which I cannot resolve.
> > 
> > If I start the LSP outside netbeans all works fine:
> > 
> > 
> > https://github.com/orat/netbeans-ocga/blob/master/src/main/java/de/orat/ma
> > th/ netbeans/ga/Test.java
> > <https://github.com/orat/netbeans-ocga/blob/master/src/main/java/de/orat/m
> > ath/netbeans/ga/Test.java>
> > 
> > So the bug is a netbeans problem and not a graalvm problem.
> > 
> > Starting via ModulInstaller or LanguageServerProvider failed:
> > 
> > Failed to get the graalvm context: java.util.ServiceConfigurationError:
> > com.oracle.truffle.api.provider.InternalResourceProvider:
> > com.oracle.truffle.runtime.LibTruffleAttachResourceProvider not a subtype
> > 
> > I have also add an isssue with some further informations to reproduce the
> > error:
> > 
> > https://github.com/oracle/graal/issues/10031
> > 
> > I have tried a lot of different things:
> > 
> > 1. Starting Netbeans with the GraalVM does not help
> > 2. Trying to use the org.netbeans.lib.truffle.api and graal-sdk instead of
> > using
> > only maven-central saved netbeans-independend libs, does not work, because
> > the
> > libs delivered with the netbeans-ide 23 do not export some packages as
> > public.
> > So I  got different error messages. Adding these packages (compiler,
> > nativeimage and word) by maven-dependency does not help. I got other error
> > messages
> > 
> > 3. Starting Netbeans with additional options
> > 
> > -J-Dgraalvm.locatorDisabled=true -J--add-exports=org.graalvm.truffle/
> > com.oracle.truffle.api.nodes=ALL-UNNAMED
> > -J--add-exports=org.graalvm.truffle/
> > com.oracle.truffle.api.exception=ALL-UNNAMED
> > -J--add-exports=org.graalvm.truffle/
> > com.oracle.truffle.api=ALL-UNNAMED -J--add-exports=org.graalvm.truffle/
> > com.oracle.truffle.api.interop=ALL-UNNAMED
> > 
> > is done but makes no difference.
> > 
> > I have added by maven dependeny the exact some version of libs as
> > delivered
> > with netbeans-23: 24.0.0.
> > 
> > The problem completly blocks further development. I have spend a couple of
> > days in fixing this but now I have no more ideas.
> > 
> > Any ideas?
> > 
> > Best regards
> > Oliver
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
> > For additional commands, e-mail: dev-h...@netbeans.apache.org
> > 
> > For further information about the NetBeans mailing lists, visit:
> > https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
For additional commands, e-mail: dev-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Reply via email to