1

I'm using Visual Studio Code 1.4.3 on Ubuntu 19.10 with Maven 3.6.3 and GraalVM graalvm-ce-java11-20.0.0. The static analysis of my java project gives me this error:

The package org.graalvm.polyglot is accessible from more than one module: <unnamed>, org.graalvm.sdk

I don't know which package does <unnamed> refer to and where to look to solve the "double import" problem.

N.B.: this error does no happen if I compile my project directly using mvn from terminal, but this actually seems to be a bug of the javac compiler, see this issue.

UPDATE The above error is raised by Visual Studio Code in each source file where I import something from org.graalvm.polyglot (e.g., import org.graalvm.polyglot.Value;) and my $CLASSPATH variable is currently empty.

UPDATE Currently inside pom.xml I have

<dependency>
  <groupId>org.graalvm.sdk</groupId>
  <artifactId>graal-sdk</artifactId>
  <version>${graalvm.version}</version>
</dependency>
<dependency>
  <groupId>org.graalvm.truffle</groupId>
  <artifactId>truffle-api</artifactId>
  <version>${graalvm.version}</version>
</dependency>-->

By trial and errors I hav found that I need to remove both dependencies in order to get rid of the error above, but in this way I get an import error for anything inside com.oracle.truffle (e.g., The import com.oracle.truffle.api cannot be resolved)

UPDATE: Running mvn clean package install -DskipTests from terminal compiles the project without any complaint.

Sirion
  • 804
  • 1
  • 11
  • 33
  • The unnamed modules is basically everything that's on the (legacy) classpath. So something is adding the `org.graalvm.polyglot` package to *both* the module-path **and** the classpath. – Joachim Sauer Mar 16 '20 at 10:35
  • I'm pretty sure `CLASSPATH` is not used in Maven. I don't know how Maven handles modules as dependencies (haven't used it in a while), but check how polyglot is declared as a dependency. Maybe it slipped in as a transitive dependency somewhere as well and one of those needs excluding. – Joachim Sauer Mar 16 '20 at 10:53
  • Thank you @JoachimSauer for you suggestions, unfortunately I'm completely new to Java and I don't know where to to look. I've updated my question with some additional info. – Sirion Mar 16 '20 at 11:18
  • Looks like it is related to bug https://github.com/quarkusio/quarkus/issues/10226 –  Jun 25 '20 at 08:59

0 Answers0