Skip to content

Use Java Application class data sharing (AppCDS). #4067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/javaServerStarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export const HEAP_DUMP = '-XX:+HeapDumpOnOutOfMemoryError';
const DEPENDENCY_COLLECTOR_IMPL= '-Daether.dependencyCollector.impl=';
const DEPENDENCY_COLLECTOR_IMPL_BF= 'bf';

const UNLOCK_DIAGNOSTIC_VM_OPTIONS= '-XX:+UnlockDiagnosticVMOptions';
const ALLOW_ARCHIVING_WITH_JAVA_AGENT= '-XX:+AllowArchivingWithJavaAgent';
const AUTO_CREATE_SHARED_ARCHIVE= '-XX:+AutoCreateSharedArchive';
const SHARED_ARCHIVE_FILE_LOC= '-XX:SharedArchiveFile=';

export function prepareExecutable(requirements: RequirementsData, workspacePath, context: ExtensionContext, isSyntaxServer: boolean): Executable {
const executable: Executable = Object.create(null);
const options: ExecutableOptions = Object.create(null);
Expand Down Expand Up @@ -90,8 +95,8 @@ export function awaitServerConnection(port): Thenable<StreamInfo> {
function prepareParams(requirements: RequirementsData, workspacePath, context: ExtensionContext, isSyntaxServer: boolean): string[] {
const params: string[] = [];
if (DEBUG) {
const port = isSyntaxServer ? 1045 : 1044;
params.push(`-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${port},quiet=y`);
// const port = isSyntaxServer ? 1045 : 1044;
// params.push(`-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${port},quiet=y`);
// suspend=y is the default. Use this form if you need to debug the server startup code:
// params.push('-agentlib:jdwp=transport=dt_socket,server=y,address=1044');
}
Expand Down Expand Up @@ -217,6 +222,18 @@ function prepareParams(requirements: RequirementsData, workspacePath, context: E
if (sharedIndexLocation) {
params.push(`-Djdt.core.sharedIndexLocation=${sharedIndexLocation}`);
}

const hasJDWP = params.find((param: string) => param.includes('jdwp')) !== undefined;
const version = getVersion(context.extensionPath);
const globalStoragePath = path.resolve(context.globalStorageUri?.fsPath, version); // .../Code/User/globalStorage/redhat.java/1.42.0/
ensureExists(globalStoragePath);
const sharedArchiveLocation = globalStoragePath ? path.join(globalStoragePath, "jdtls.jsa") : undefined;
if (vmargs.indexOf(SHARED_ARCHIVE_FILE_LOC) < 0 && !hasJDWP) {
params.push(UNLOCK_DIAGNOSTIC_VM_OPTIONS);
params.push(ALLOW_ARCHIVING_WITH_JAVA_AGENT); // required due to use of '-javaagent'
params.push(AUTO_CREATE_SHARED_ARCHIVE);
params.push(`${SHARED_ARCHIVE_FILE_LOC}${sharedArchiveLocation}`);
}
}

// "OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify
Expand Down