Skip to content

Commit 9b68dc6

Browse files
committed
move src directories
1 parent 381f10b commit 9b68dc6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+80
-81
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
FROM mcr.microsoft.com/devcontainers/javascript-node:22
22

33
RUN apt-get update
4-
RUN apt-get install -y openjdk-17-jdk gdb clang-format
4+
RUN apt-get install -y openjdk-17-jdk maven gdb clang-format

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"clazzclazz",
55
"Ferner",
66
"jarray",
7+
"javac",
78
"jboolean",
89
"jbyte",
910
"jchar",

README.md

Lines changed: 3 additions & 16 deletions

binding.gyp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
'target_arch': 's390'
1414
}],
1515
['OS=="win"', {
16-
'javahome%': '<!(node findJavaHome.js)'
16+
'javahome%': '<!(node ./scripts/findJavaHome.js)'
1717
}],
1818
['OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" or OS=="zos"', {
19-
'javahome%': '<!(node findJavaHome.js)'
19+
'javahome%': '<!(node ./scripts/findJavaHome.js)'
2020
}],
2121
['OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" or OS=="zos"', {
22-
'javalibdir%': "<!(./find_java_libdir.sh <(target_arch) <(OS))"
22+
'javalibdir%': "<!(./scripts/find_java_libdir.sh <(target_arch) <(OS))"
2323
}],
2424
['OS=="zos"', {
2525
'nodever%': '<!(node -e "console.log(process.versions.node)" | cut -d"." -f1)'
@@ -30,12 +30,12 @@
3030
{
3131
'target_name': 'nodejavabridge_bindings',
3232
'sources': [
33-
'src/java.cpp',
34-
'src/javaObject.cpp',
35-
'src/javaScope.cpp',
36-
'src/methodCallBaton.cpp',
37-
'src/nodeJavaBridge.cpp',
38-
'src/utils.cpp'
33+
'src-cpp/java.cpp',
34+
'src-cpp/javaObject.cpp',
35+
'src-cpp/javaScope.cpp',
36+
'src-cpp/methodCallBaton.cpp',
37+
'src-cpp/nodeJavaBridge.cpp',
38+
'src-cpp/utils.cpp'
3939
],
4040
'include_dirs': [
4141
'<(javahome)/include',

compile-java.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require("./lib/nodeJavaBridge");
1+
module.exports = require("./src-node/nodeJavaBridge");

jarjar.rule

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@
4343
},
4444
"scripts": {
4545
"install": "node-gyp rebuild",
46-
"test": "node testRunner.js",
47-
"postinstall": "node postInstall.js",
46+
"clean": "rm -rf build",
47+
"test": "node ./scripts/testRunner.js",
48+
"postinstall": "node ./scripts/postInstall.js",
4849
"lint": "eslint --ext js,ts,tsx --report-unused-disable-directives --max-warnings 0 .",
4950
"format": "prettier --write .",
50-
"format-cpp": "clang-format --version; find src/ -iname '*.h' -o -iname '*.cpp' | xargs clang-format -i",
51+
"format-cpp": "clang-format --version; find src-cpp/ -iname '*.h' -o -iname '*.cpp' | xargs clang-format -i",
5152
"precommit": "npm run format-cpp && npm run format && npm run lint && npm test"
5253
},
5354
"main": "./index.js"

scripts/compile-java.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
SCRIPT_DIR=$(dirname "$0")
5+
cd "${SCRIPT_DIR}/.."
6+
7+
if [ -z "${JAVA_HOME:-}" ] && [ -e "/usr/libexec/java_home" ]; then
8+
export JAVA_HOME=$(/usr/libexec/java_home -v 11)
9+
fi
10+
11+
echo "Using $(javac -version)."
12+
set -x
13+
14+
javac -source 1.8 -target 1.8 src-java/node/*.java
15+
javac -source 1.8 -target 1.8 test/*.java
16+
javac -classpath src-java -h ./src-cpp src-java/node/NodeDynamicProxyClass.java
17+
echo "complete!"
File renamed without changes.

find_java_libdir.sh renamed to scripts/find_java_libdir.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env bash
2-
32
set -eu
43

4+
SCRIPT_DIR=$(dirname "$0")
5+
cd "${SCRIPT_DIR}/.."
6+
57
error() {
68
echo "error: $*" >&2
79
exit 1
@@ -12,7 +14,7 @@ main () {
1214
local os=$2
1315

1416
local java_home full_java_version java_version
15-
java_home=$(node findJavaHome.js)
17+
java_home=$(node ./scripts/findJavaHome.js)
1618
full_java_version=$(${java_home}/bin/java -version 2>&1 | grep version | sed -e 's/.*version "\(.*\)"\(.*\)/\1/; 1q')
1719

1820
if [[ "${full_java_version}" = "1."* ]]

postInstall.js renamed to scripts/postInstall.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require("find-java-home")((err, home) => {
1717
const binary = dll ?? dylib ?? so;
1818

1919
fs.writeFileSync(
20-
path.resolve(__dirname, "./build/jvm_dll_path.json"),
20+
path.resolve(__dirname, "../build/jvm_dll_path.json"),
2121
binary ? JSON.stringify(path.delimiter + path.dirname(path.resolve(home, binary))) : '""'
2222
);
2323
}

testRunner.js renamed to scripts/testRunner.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const glob = require("glob");
1010
const path = require("node:path");
1111

1212
const tests = glob
13-
.sync(path.join("testAsyncOptions", "*.test.js"))
13+
.sync("*.test.js", { cwd: path.join(__dirname, "..", "testAsyncOptions") })
1414
.sort((a, b) => a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase()));
1515

1616
tests.unshift("test"); // Arrange to run the primary tests first, in a single process
@@ -19,7 +19,7 @@ function runTest(testArgs, done) {
1919
const vitest = path.join("node_modules", ".bin", "vitest");
2020
const cmd = testArgs === "test" ? `vitest --dir test` : `${vitest} ${testArgs}`;
2121
console.log(`running "${cmd}"...`);
22-
childProcess.exec(cmd, function (error, stdout, stderr) {
22+
childProcess.exec(cmd, (error, stdout, stderr) => {
2323
const errText = stderr.toString();
2424
if (errText !== "") {
2525
console.error(chalk.bold.red(errText));
@@ -30,7 +30,8 @@ function runTest(testArgs, done) {
3030
});
3131
}
3232

33-
async.eachSeries(tests, runTest, function (err) {
33+
console.log('test to run', tests);
34+
async.eachSeries(tests, runTest, (err) => {
3435
if (err) {
3536
console.error(chalk.bold.red(err));
3637
process.exit(1);

scripts/update-commons-lang.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
SCRIPT_DIR=$(dirname "$0")
5+
cd "${SCRIPT_DIR}/.."
6+
7+
if [ -d build/commons-lang ]; then
8+
cd build/commons-lang
9+
git pull
10+
else
11+
mkdir -p build
12+
cd build
13+
git clone --depth 1 [email protected]:apache/commons-lang.git
14+
cd commons-lang
15+
fi
16+
17+
mvn clean compile package -DskipTests
18+
java -jar ../../src-java/jarjar-1.4.jar process ../../src-java/commons-lang.jarjar.rules target/commons-lang3*-SNAPSHOT.jar ../../src-java/commons-lang3-node-java.jar
19+
20+
echo "complete!"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src-java/node/CastingUtils.class

0 Bytes
Binary file not shown.

src-java/node/MethodCallBaton.class

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

src-java/node/NodeJsException.class

0 Bytes
Binary file not shown.

src-java/node/VarArgs.class

0 Bytes
Binary file not shown.

lib/nodeJavaBridge.js renamed to src-node/nodeJavaBridge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (!binaryPath) {
2020
const bindings = require(binaryPath);
2121

2222
const java = (module.exports = new bindings.Java());
23-
java.classpath.push(path.resolve(__dirname, "../commons-lang3-node-java.jar"));
23+
java.classpath.push(path.resolve(__dirname, "../src-java/commons-lang3-node-java.jar"));
2424
java.classpath.push(path.resolve(__dirname, __dirname, "../src-java"));
2525
java.classpath.pushDir = function (dir) {
2626
fs.readdirSync(dir).forEach(function (file) {

test/ListenerInterface.class

0 Bytes
Binary file not shown.

test/ListenerTester.class

0 Bytes
Binary file not shown.

test/RunInterface$1.class

20 Bytes
Binary file not shown.

test/RunInterface$Interface0Arg.class

0 Bytes
Binary file not shown.

test/RunInterface$Interface1Arg.class

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

test/RunInterface.class

0 Bytes
Binary file not shown.

test/Test$Enum.class

59 Bytes
Binary file not shown.

test/Test$StaticEnum.class

59 Bytes
Binary file not shown.

test/Test$SubClass.class

0 Bytes
Binary file not shown.

test/Test$SuperClass.class

0 Bytes
Binary file not shown.

test/Test.class

0 Bytes
Binary file not shown.

test/TestExceptions.class

0 Bytes
Binary file not shown.

test/TestLambda$IntegerMath.class

0 Bytes
Binary file not shown.

test/TestLambda.class

0 Bytes
Binary file not shown.

testAsyncOptions/allThreeSuffix.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("allThreeSuffix", () => {
2626
});
2727

2828
test("importClass", () => {
29-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
29+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
3030
const ArrayList = java.import("java.util.ArrayList");
3131
expect(ArrayList).toBeTruthy();
3232
const arrayList = new ArrayList();
@@ -54,7 +54,7 @@ describe("allThreeSuffix", () => {
5454
});
5555

5656
test("staticSyncCalls", () => {
57-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
57+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
5858
// Among other things, java.import creates Sync functions for static methods.
5959
const String = java.import("java.lang.String");
6060
expect(String.formatSync("%s--%s", "hello", "world")).toBe("hello--world");

testAsyncOptions/asyncSuffixSyncDefault.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe("asyncSuffixSyncDefault", () => {
4747
});
4848

4949
test("importClass", () => {
50-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
50+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
5151
const ArrayList = java.import("java.util.ArrayList");
5252
expect(ArrayList).toBeTruthy();
5353
const arrayList = new ArrayList();
@@ -75,7 +75,7 @@ describe("asyncSuffixSyncDefault", () => {
7575
});
7676

7777
test("staticSyncCalls", () => {
78-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
78+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
7979
// Among other things, java.import creates Sync functions for static methods.
8080
const String = java.import("java.lang.String");
8181
expect(String.format("%s--%s", "hello", "world")).toBe("hello--world");

testAsyncOptions/defacto.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe("defacto", () => {
5454
});
5555

5656
test("importClass", () => {
57-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
57+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
5858
const ArrayList = java.import("java.util.ArrayList");
5959
expect(ArrayList).toBeTruthy();
6060
const arrayList = new ArrayList();
@@ -82,7 +82,7 @@ describe("defacto", () => {
8282
});
8383

8484
test("staticSyncCalls", () => {
85-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
85+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
8686
// Among other things, java.import creates Sync functions for static methods.
8787
const String = java.import("java.lang.String");
8888
expect(String.formatSync("%s--%s", "hello", "world")).toBe("hello--world");

testAsyncOptions/defactoPlusPromise.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("defactoPlusPromise", () => {
4949
});
5050

5151
test("importClass", () => {
52-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
52+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
5353
const ArrayList = java.import("java.util.ArrayList");
5454
expect(ArrayList).toBeTruthy();
5555
const arrayList = new ArrayList();
@@ -77,7 +77,7 @@ describe("defactoPlusPromise", () => {
7777
});
7878

7979
test("staticSyncCalls", () => {
80-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
80+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
8181
// Among other things, java.import creates Sync functions for static methods.
8282
const String = java.import("java.lang.String");
8383
expect(String.formatSync("%s--%s", "hello", "world")).toBe("hello--world");

testAsyncOptions/default.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe("default", () => {
1919
});
2020

2121
test("importClass", () => {
22-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
22+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
2323
const ArrayList = java.import("java.util.ArrayList");
2424
expect(ArrayList).toBeTruthy();
2525
const arrayList = new ArrayList();
@@ -47,7 +47,7 @@ describe("default", () => {
4747
});
4848

4949
test("staticSyncCalls", () => {
50-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
50+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
5151
// Among other things, java.import creates Sync functions for static methods.
5252
const String = java.import("java.lang.String");
5353
expect(String.formatSync("%s--%s", "hello", "world")).toBe("hello--world");

testAsyncOptions/noAsync.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe("noAsync", () => {
5858
});
5959

6060
test("importClass", () => {
61-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
61+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
6262
const ArrayList = java.import("java.util.ArrayList");
6363
expect(ArrayList).toBeTruthy();
6464
const arrayList = new ArrayList();
@@ -86,7 +86,7 @@ describe("noAsync", () => {
8686
});
8787

8888
test("sStaticSyncCalls", () => {
89-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
89+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
9090
// Among other things, java.import creates Sync functions for static methods.
9191
const String = java.import("java.lang.String");
9292
expect(String.formatSync("%s--%s", "hello", "world")).toBe("hello--world");

testAsyncOptions/syncDefaultPlusPromise.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("syncDefaultPlusPromise", () => {
2323
});
2424

2525
test("importClass", () => {
26-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
26+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
2727
// This test verifies the import runs without error.
2828
const ArrayList = java.import("java.util.ArrayList");
2929
expect(ArrayList).toBeTruthy();
@@ -52,7 +52,7 @@ describe("syncDefaultPlusPromise", () => {
5252
});
5353

5454
test("staticSyncCalls", () => {
55-
// Note: java.import executes javascript code in lib/nodeJavaBridge that makes sync calls to java classes.
55+
// Note: java.import executes javascript code in src-node/nodeJavaBridge that makes sync calls to java classes.
5656
// Among other things, java.import creates Sync functions for static methods.
5757
const String = java.import("java.lang.String");
5858
expect(String.format("%s--%s", "hello", "world")).toBe("hello--world");

testHelpers.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ java.options.push("-Djava.awt.headless=true");
44

55
java.classpath.push("test/");
66
java.classpath.push("test/commons-lang3-3.1.jar");
7-
java.classpath.push("test8/");
87

98
export function getJava(asyncOptions) {
109
java.asyncOptions = asyncOptions ?? {

update-commons-lang.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)