Skip to content

Commit b88d402

Browse files
committed
WIP: enable javac-based compilation
Signed-off-by: Fred Bricon <[email protected]>
1 parent 248e976 commit b88d402

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,17 @@
404404
"scope": "window",
405405
"order": 90
406406
},
407+
"java.jdt.ls.javac.enabled": {
408+
"type": "string",
409+
"enum": [
410+
"on",
411+
"off"
412+
],
413+
"default": "off",
414+
"markdownDescription": "[Experimental] Specify whether to enable Javac-based compilation in the language server. Requires running this extension with Java 22",
415+
"scope": "window",
416+
"order": 95
417+
},
407418
"java.trace.server": {
408419
"type": "string",
409420
"enum": [
@@ -1903,4 +1914,4 @@
19031914
},
19041915
"segmentWriteKey": "Y7Y5Xk8dKEhVZHTmAkFZkqgdN4d7c4lt",
19051916
"segmentWriteKeyDebug": "BflPll7uuKOCm3y0g7JpfXLVBVFBivDE"
1906-
}
1917+
}

src/javaServerStarter.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,36 @@ function prepareParams(requirements: RequirementsData, workspacePath, context: E
106106
// See https://github.com/redhat-developer/vscode-java/issues/2264
107107
// It requires the internal API sun.nio.fs.WindowsFileAttributes.isDirectoryLink() to check if a Windows directory is symlink.
108108
'--add-opens',
109-
'java.base/sun.nio.fs=ALL-UNNAMED');
109+
'java.base/sun.nio.fs=ALL-UNNAMED'
110+
);
111+
112+
const javacEnabled = 'on' === getJavaConfiguration().get('jdt.ls.javac.enabled');
113+
if (javacEnabled) {
114+
// Javac flags
115+
params.push(
116+
'--add-opens',
117+
'jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
118+
'--add-opens',
119+
'jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
120+
'--add-opens',
121+
'jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
122+
'--add-opens',
123+
'jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
124+
'--add-opens',
125+
'jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
126+
'--add-opens',
127+
'jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
128+
'--add-opens',
129+
'jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
130+
'--add-opens',
131+
'jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
132+
'-DICompilationUnitResolver=org.eclipse.jdt.core.dom.JavacCompilationUnitResolver',
133+
'-DCompilationUnit.DOM_BASED_OPERATIONS=true',
134+
// Javac based completion is useless for now
135+
// '-DCompilationUnit.codeComplete.DOM_BASED_OPERATIONS=true',
136+
'-DAbstractImageBuilder.compiler=org.eclipse.jdt.internal.javac.JavacCompiler'
137+
);
138+
}
110139

111140
params.push('-Declipse.application=org.eclipse.jdt.ls.core.id1',
112141
'-Dosgi.bundles.defaultStartLevel=4',

src/requirements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { logger } from './log';
1010
import { checkJavaPreferences } from './settings';
1111
import { listJdks, sortJdksBySource, sortJdksByVersion } from './jdkUtils';
1212

13-
const REQUIRED_JDK_VERSION = 17;
13+
const REQUIRED_JDK_VERSION = 22;
1414
/* eslint-disable @typescript-eslint/naming-convention */
1515
export interface RequirementsData {
1616
tooling_jre: string;

src/settings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ function hasJavaConfigChanged(oldConfig: WorkspaceConfiguration, newConfig: Work
136136
|| hasConfigKeyChanged('jdt.ls.vmargs', oldConfig, newConfig)
137137
|| hasConfigKeyChanged('server.launchMode', oldConfig, newConfig)
138138
|| hasConfigKeyChanged('sharedIndexes.location', oldConfig, newConfig)
139-
|| hasConfigKeyChanged('transport', oldConfig, newConfig);
139+
|| hasConfigKeyChanged('transport', oldConfig, newConfig)
140+
|| hasConfigKeyChanged('jdt.ls.javac.enabled', oldConfig, newConfig);
140141
}
141142

142143
function hasConfigKeyChanged(key, oldConfig, newConfig) {

0 commit comments

Comments
 (0)