Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit 746798b

Browse files
Suppress Sun unsafe memory warnings on JDK 24
1 parent a82d2d5 commit 746798b

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

packages/google-closure-compiler/lib/node/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default class Compiler {
6565
/** @param {function(number, string, string)=} callback */
6666
run(callback) {
6767
if (this.JAR_PATH) {
68-
this.commandArguments.unshift('-jar', this.JAR_PATH);
68+
this.commandArguments.unshift('--sun-misc-unsafe-memory-access=allow', '-jar', this.JAR_PATH);
6969
if (this.extraCommandArgs) {
7070
this.commandArguments.unshift(...this.extraCommandArgs);
7171
}

packages/google-closure-compiler/test/node.js

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ describe('closure-compiler node bindings', () => {
3939

4040
describe('java version', () => {
4141
let originalTimeout;
42+
const compilerArgs = [
43+
'-Xms2048m',
44+
'--sun-misc-unsafe-memory-access=allow',
45+
'-jar',
46+
JAR_PATH,
47+
'--one=true',
48+
'--two=two',
49+
'--three=one',
50+
'--three=two',
51+
'--three=three',
52+
];
4253
beforeEach(() => {
4354
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
4455
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
@@ -65,26 +76,24 @@ describe('closure-compiler node bindings', () => {
6576
expect(hasRun).toBe(true);
6677
});
6778

68-
it('should normalize an options object to an arguments array', () => {
79+
it('should normalize an options object to an arguments array', async () => {
6980
const compiler = new Compiler({
7081
one: true,
7182
two: 'two',
7283
three: ['one', 'two', 'three']
7384
});
85+
await new Promise((resolve) => compiler.run(resolve));
7486

75-
const expectedArray = ['--one=true', '--two=two',
76-
'--three=one', '--three=two', '--three=three'];
87+
const expectedArray = compilerArgs.slice(1);
7788
expect(compiler.commandArguments.length).toBe(expectedArray.length);
7889
compiler.commandArguments.forEach((item, index) => {
7990
expect(expectedArray[index]).toBe(item);
8091
});
8192
});
8293

8394
it('should prepend the -jar argument and compiler path when configured by array', async () => {
84-
const expectedArray = ['-jar', JAR_PATH, '--one=true', '--two=two',
85-
'--three=one', '--three=two', '--three=three'];
86-
87-
const compiler = new Compiler(expectedArray.slice(2));
95+
const expectedArray = compilerArgs.slice(1);
96+
const compiler = new Compiler(expectedArray.slice(3));
8897
await new Promise((resolve) => compiler.run(resolve));
8998

9099
expect(compiler.commandArguments.length).toBe(expectedArray.length);
@@ -95,10 +104,13 @@ describe('closure-compiler node bindings', () => {
95104

96105
describe('extra command arguments', () => {
97106
it('should include initial command arguments when configured by an options object', async () => {
98-
const expectedArray = ['-Xms2048m', '-jar', JAR_PATH, '--one=true', '--two=two',
99-
'--three=one', '--three=two', '--three=three'];
100-
101-
const compiler = new Compiler(expectedArray.slice(3), expectedArray.slice(0, 1));
107+
const args = {
108+
one: true,
109+
two: 'two',
110+
three: ['one', 'two', 'three'],
111+
};
112+
const expectedArray = compilerArgs;
113+
const compiler = new Compiler(args, compilerArgs.slice(0, 1));
102114
await new Promise((resolve) => compiler.run(resolve));
103115

104116
expect(compiler.commandArguments.length).toBe(expectedArray.length);
@@ -108,10 +120,8 @@ describe('closure-compiler node bindings', () => {
108120
});
109121

110122
it('should include initial command arguments when configured by array', async () => {
111-
const expectedArray = ['-Xms2048m', '-jar', JAR_PATH, '--one=true', '--two=two',
112-
'--three=one', '--three=two', '--three=three'];
113-
114-
const compiler = new Compiler(expectedArray.slice(3), expectedArray.slice(0, 1));
123+
const expectedArray = compilerArgs;
124+
const compiler = new Compiler(expectedArray.slice(4), expectedArray.slice(0, 1));
115125
await new Promise((resolve) => compiler.run(resolve));
116126
expect(compiler.commandArguments.length).toBe(expectedArray.length);
117127
compiler.commandArguments.forEach(function (item, index) {

0 commit comments

Comments
 (0)