vscode-java
vscode-java copied to clipboard
Missing Gradle project configuration file: .settings/org.eclipse.buildship.core.prefs
[provide a description of the issue]
Environment
env:
- Visual Studio Code version: latest
- Java extension version: 1.7
- apple m1 pro
- latest java pack
- use Oracle JDK 1.8 to run the program, and use OpenJDK 17 to jdt, as the java server.
Steps To Reproduce
1、use Oracle JDK 1.8 to run the program, and use OpenJDK 17 to jdt, as the java server. 2、compile https://github.com/tronprotocol/java-tron
[Please attach a sample project reproducing the error] Please attach logs
Current Result
Error, Access restriction: The type 'OperatingSystemMXBean' is not API . Can't debug
Expected Result
No error
Additional Informations
java compile server some info as follow:
!ENTRY org.eclipse.jdt.ls.core 4 0 2022-06-24 00:40:59.039 !MESSAGE Error occured while building workspace. Details: message: Access restriction: The method 'OperatingSystemMXBean.getProcessCpuLoad()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 70 message: Access restriction: The method 'OperatingSystemMXBean.getSystemCpuLoad()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 78 message: Access restriction: The method 'OperatingSystemMXBean.getTotalPhysicalMemorySize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 94 message: Access restriction: The method 'OperatingSystemMXBean.getFreePhysicalMemorySize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 102 message: Access restriction: The method 'OperatingSystemMXBean.getTotalSwapSpaceSize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 109 message: Access restriction: The method 'OperatingSystemMXBean.getFreeSwapSpaceSize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 116 message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 5 message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 44 message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 47 message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 51 message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 3 message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 41 message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 41 message: Access restriction: The method 'OperatingSystemMXBean.getTotalPhysicalMemorySize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 75 message: Access restriction: The method 'OperatingSystemMXBean.getFreePhysicalMemorySize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 76 message: Access restriction: The method 'OperatingSystemMXBean.getSystemCpuLoad()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 77 message: Access restriction: The method 'OperatingSystemMXBean.getProcessCpuLoad()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 84
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-06-24 00:41:01.712 !MESSAGE >> workspace/executeCommand vscode.java.resolveBuildFiles
Help! It's been bothering me two days. @fbricon @Eskibear @gbraad @LightGuard @otaviof
Please, do not just at-reply users to get attention. I have no idea what this is about.
Especially as you just filed the issue and expect people to jump to your help. We also have a job and a life.
Please, do not just at-reply users to get attention. I have no idea what this is about.
Especially as you just filed the issue and expect people to jump to your help. We also have a job and a life.
Oh, sorry, It's github's Recommended. My fault. Have a good day.
Recommended? This must be very wrong as it also includes people who aren't members of the organization.
Really can't help. Using the com.sun.* packages have never been recommended. They're internal classes subject to change anytime.
Recommended? This must be very wrong as it also includes people who aren't members of the organization.
Apologize again. Happy weekend! 😄
Really can't help. Using the com.sun.* packages have never been recommended. They're internal classes subject to change anytime.
Thx! okay, I got it. An open-source project that I study recently dependency the com.sun.* packages, I will remind the project side. Have a nice weekend.
@ai-chen2050 I can reproduce this. IIUC The problems "xxx is not API" will not stop you from debugging, but you just encountered another error about missing prefs file
, which might block you. Here is a workaround:
- Set
java.import.generatesMetadataFilesAtProjectRoot
totrue
(better in workspace scope) - Press F1 to open the command palette, type
Java: Clean Java Language Server Workspace
, run this command - After reloading and importing, your project might remain only "xxx is not API" errors, and you might be able to debug, just choose
Proceed
if there is any tips about the error.
I can also reproduce it via:
- clone https://github.com/spring-projects/spring-petclinic
- open it in eclipse, by default, eclipse will import it as a Maven project and generate metadata files
- open this project in VS Code, there is a notification shows to choose build tool, choose "Gradle"
- The same error appears.
Thanks for the workaround @CsCherrYY, I had the same issue on GitHub Codespaces and your workaround worked perfectly.
@ai-chen2050 I fixed "xxx is not API" errors in a gradle project like this:
build.gradle.kts
plugins {
eclipse
// other plugins ...
}
eclipse {
classpath {
file {
whenMerged {
val classpath = this as org.gradle.plugins.ide.eclipse.model.Classpath
val jre = classpath.entries.find {
when (it) {
is org.gradle.plugins.ide.eclipse.model.Container -> it.path.contains("org.eclipse.jdt.launching.JRE_CONTAINER")
else -> false
}
} as org.gradle.plugins.ide.eclipse.model.Container
jre.accessRules.add(org.gradle.plugins.ide.eclipse.model.AccessRule("accessible", "com/sun/net/**"))
}
}
}
}