Vscode-java: Java 10: The type java.lang.Object cannot be resolved

Created on 29 Mar 2018  Â·  11Comments  Â·  Source: redhat-developer/vscode-java

Environment
  • Operating System:
$ uname -a
Linux localhost.localdomain 4.15.9-200.fc26.x86_64 #1 SMP Mon Mar 12 17:11:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • JDK version: openjdk version "10" 2018-03-20
  • Visual Studio Code version:
Version 1.21.1
Commit 79b44aa704ce542d8ca4a3cc44cfca566e7720f1
Date 2018-03-14T14:46:30.761Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
  • Java extension version: 021.0
Steps To Reproduce
  1. These:
wget https://download.java.net/java/GA/jdk10/10/binaries/openjdk-10_linux-x64_bin.tar.gz
tar xf openjdk-10_linux-x64_bin.tar.gz
pushd jdk-10
export JAVA_HOME=export JAVA_HOME=$(pwd)
popd
git clone [email protected]:elastic/elasticsearch.git
pushd elasticsearch
code .
  1. Open a java file like Bootstrap.java to kick of the language service.
  2. Mouse over /* on line 1. You get
The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

I get a bunch of errors in the logs like:

message: Unbound classpath container: 'JRE System Library [JavaSE-1.8]' in project ':benchmarks';code: 963

And some around cycles but I don't think either of these are a problem here because when I restart with Java 9 like so:

echo Drop back to the last commit that supported java 9
git checkout eebda6974dea3445d5a4043a843d206046861470
export JAVA_HOME=/usr/java/jdk-9.0.4
rm -rf ~/.config/Code/User/workspaceStorage/*
code .

I once again get definitions for things like Object.

If I jump back to java 10 while still on the java 9 supporting commit and restart everything breaks again.

I haven't tested this outside of Elasticsearch because I don't have another project handy but I don't see any issues around Java 10 so I kind of expected it to just work.

upstream

Most helpful comment

You can try http://download.jboss.org/jbosstools/jdt.ls/staging/java-0.22.0-912.vsix

Works for me. Thanks for the quick response, @snjeza!

All 11 comments

I verified that java 10 doesn't work with an empty projects made by gradle init --type java-library.

Ah! A new error message:

message: Unbound classpath container: 'JRE System Library [JavaSE-10]' in project 't';code: 963

I'm facing the same issue.

  • Operating System: Windows 7 Ultimate Service Pack 1
  • Java version:
    java version "10" 2018-03-20
    Java(TM) SE Runtime Environment 18.3 (build 10+46)
    Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
  • Visual Studio code version:
    Version 1.21.1 Commit 79b44aa704ce542d8ca4a3cc44cfca566 e7720f1 Date 2018-03-14T14:46:47.128Z Shell 1.7.9 Renderer 58.0.3029.110 Node 7.9.0 Architecture x64
  • Language support for Java extension version: v0.21.0
  • Maven for Java extension version: v0.6.0

Steps to reproduce:

  1. Using the 'Maven for Java' extension, generate a new project archetype by the name, maven-archetype-quickstart.
  2. Open one of the .java files in the project to kick off the Language Support.
  3. Mouse over any of the import statements. You will get errors like:
    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
    and
    The import java.util cannot be resolved

From @Snjeza it looks like has been fixed upstream so we're just waiting in
them to release and vscode-java to upgrade.

I'm stuck on Java 10 so this issue prevents me from using vscode-java. I
admit I'm probably in the minority. We try to keep up with all the new Java
releases to be good open source citizens but lots of projects don't have
time for that.

On Sat, Mar 31, 2018, 3:15 AM ChirayuShishodiya notifications@github.com
wrote:

I'm facing the same issue.

  • Operating System: Windows 7 Ultimate Service Pack 1
  • Java version:
    java version "10" 2018-03-20
    Java(TM) SE Runtime Environment 18.3 (build 10+46)
    Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
  • Visual Studio code version:
    Version 1.21.1 Commit 79b44aa704ce542d8ca4a3cc44cfca566 e7720f1 Date
    2018-03-14T14:46:47.128Z Shell 1.7.9 Renderer 58.0.3029.110 Node 7.9.0
    Architecture x64
  • Language support for Java extension version: v0.21.0
  • Maven for Java extension version: v0.6.0

Steps to reproduce:

  1. Using the 'Maven for Java' extension, generate a new project
    archetype by the name, maven-archetype-quickstart.
  2. Open one of the .java files in the project to kick off the Language
    Support.
  3. Mouse over any of the import statements. You will get errors like:
    The type java.lang.Object cannot be resolved. It is indirectly
    referenced from required .class files
    and
    The import java.util cannot be resolved

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/redhat-developer/vscode-java/issues/483#issuecomment-377672565,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AANLoq9HCRvwHIigE-abDB7ug_f4l6b6ks5tjyzzgaJpZM4TAgmx
.

message: Unbound classpath container: 'JRE System Library [JavaSE-10]' in project 't';code: 963

The JavaSE-10 execution environment will be available in Photon 4.8M7. It's already available in http://download.eclipse.org/eclipse/downloads/drops4/I20180330-2235/

@snjeza feel free to update the TP to pick up the latest photon I-Build with Java 10 support

Thanks @snjeza!

You can try http://download.jboss.org/jbosstools/jdt.ls/staging/java-0.22.0-912.vsix

Works for me. Thanks for the quick response, @snjeza!

I think I need to install java 8 to resolve some issues.
Yesterday, it worked and to day, it show me many errors

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bkbonner picture bkbonner  Â·  3Comments

protoEvangelion picture protoEvangelion  Â·  3Comments

jcjolley picture jcjolley  Â·  3Comments

sfariaNG picture sfariaNG  Â·  3Comments

gorkem picture gorkem  Â·  4Comments