From ef2cd5c89957553a33e778241c9589816573f9bc Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Tue, 7 Nov 2023 19:31:50 +0900 Subject: [PATCH 1/8] [Feat]: Support JDK8 and update CI --- .github/workflows/cicd.yml | 13 +++++++++---- .github/workflows/coverage.yml | 7 ++++++- .github/workflows/test-nist.yml | 9 +++++++-- .github/workflows/test-other.yml | 9 +++++++-- libcobj/app/build.gradle.kts | 2 +- .../libcobj/file/CobolIndexedFile.java | 14 +++++++------- .../libcobj/file/IndexedCursor.java | 16 ++++++++-------- 7 files changed, 45 insertions(+), 25 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 80027df6..724725f9 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -17,18 +17,23 @@ jobs: container: image: ${{ matrix.os }} steps: - + + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '8' + - name: Install dependencies on Ubuntu 22.04 if: matrix.os == 'ubuntu:22.04' run: | apt update -y - apt install -y default-jdk build-essential bison flex gettext texinfo automake autoconf + apt install -y build-essential bison flex gettext texinfo automake autoconf - name: Install dependencies on AlmaLinux 9 if: matrix.os == 'almalinux:9' run: | dnf -y update - dnf install -y java-17-openjdk-devel gcc make bison flex automake autoconf diffutils gettext + dnf install -y gcc make bison flex automake autoconf diffutils gettext - name: Checkout opensource COBOL 4J uses: actions/checkout@v3 @@ -90,7 +95,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17' + java-version: '8' - name: Install static analysis tools run: | diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 0d190792..550cbe58 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -10,7 +10,12 @@ jobs: run-tests: runs-on: ubuntu-latest steps: - + + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '8' + - name: Install dependencies on Ubuntu 22.04 run: | sudo apt update -y diff --git a/.github/workflows/test-nist.yml b/.github/workflows/test-nist.yml index 511950df..242be95b 100644 --- a/.github/workflows/test-nist.yml +++ b/.github/workflows/test-nist.yml @@ -29,17 +29,22 @@ jobs: with: name: opensourcecobol4j-${{ env.ARTIFACT_NAME }} + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '8' + - name: Install dependencies on Ubuntu 22.04 if: matrix.os == 'ubuntu:22.04' run: | apt update -y - apt install -y default-jdk build-essential + apt install -y build-essential - name: Install dependencies on AlmaLinux 9 if: matrix.os == 'almalinux:9' run: | dnf -y update - dnf install -y java-17-openjdk-devel gcc make perl + dnf install -y gcc make perl - name: Install opensource COBOL 4J run: | diff --git a/.github/workflows/test-other.yml b/.github/workflows/test-other.yml index 97bbb64b..1bc02118 100644 --- a/.github/workflows/test-other.yml +++ b/.github/workflows/test-other.yml @@ -26,17 +26,22 @@ jobs: with: name: opensourcecobol4j-${{ env.ARTIFACT_NAME }} + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '8' + - name: Install dependencies on Ubuntu 22.04 if: matrix.os == 'ubuntu:22.04' run: | apt update -y - apt install -y default-jdk build-essential + apt install -y build-essential - name: Install dependencies on AlmaLinux 9 if: matrix.os == 'almalinux:9' run: | dnf -y update - dnf install -y java-17-openjdk-devel gcc make diffutils + dnf install -y gcc make diffutils - name: Install opensource COBOL 4J run: | diff --git a/libcobj/app/build.gradle.kts b/libcobj/app/build.gradle.kts index 2393508c..45553248 100644 --- a/libcobj/app/build.gradle.kts +++ b/libcobj/app/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion.set(JavaLanguageVersion.of(8)) } } diff --git a/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/CobolIndexedFile.java b/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/CobolIndexedFile.java index abce08d2..03373a50 100644 --- a/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/CobolIndexedFile.java +++ b/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/CobolIndexedFile.java @@ -256,7 +256,7 @@ public int indexed_start_internal( boolean isDuplicate = this.keys[p.key_index].getFlag() != 0; this.cursor = IndexedCursor.createCursor(p.connection, p.key, p.key_index, isDuplicate, cond); - if (this.cursor.isEmpty()) { + if (!this.cursor.isPresent()) { return COB_STATUS_30_PERMANENT_ERROR; } @@ -316,25 +316,25 @@ public int readNext(int readOpts) { if (this.indexedFirstRead || this.flag_begin_of_file) { this.cursor = IndexedCursor.createCursor(p.connection, p.key, p.key_index, isDuplicate, COB_GE); - if (this.cursor.isEmpty()) { + if (!this.cursor.isPresent()) { return COB_STATUS_10_END_OF_FILE; } this.cursor.get().moveToFirst(); } else if (this.flag_end_of_file) { this.cursor = IndexedCursor.createCursor(p.connection, p.key, p.key_index, isDuplicate, COB_LE); - if (this.cursor.isEmpty()) { + if (!this.cursor.isPresent()) { return COB_STATUS_30_PERMANENT_ERROR; } this.cursor.get().moveToLast(); } else if (this.updateWhileReading) { this.updateWhileReading = false; - if (this.cursor.isEmpty()) { + if (!this.cursor.isPresent()) { return COB_STATUS_30_PERMANENT_ERROR; } IndexedCursor oldCursor = this.cursor.get(); Optional newCursor = oldCursor.reloadCursor(); - if (newCursor.isEmpty()) { + if (!newCursor.isPresent()) { this.cursor = Optional.of(oldCursor); } else { oldCursor.close(); @@ -342,7 +342,7 @@ public int readNext(int readOpts) { } } - if (this.cursor.isEmpty()) { + if (!this.cursor.isPresent()) { return COB_STATUS_30_PERMANENT_ERROR; } @@ -361,7 +361,7 @@ public int readNext(int readOpts) { this.indexedFirstRead = false; - if (optionalResult.isEmpty()) { + if (!optionalResult.isPresent()) { return COB_STATUS_10_END_OF_FILE; } else { FetchResult result = optionalResult.get(); diff --git a/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/IndexedCursor.java b/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/IndexedCursor.java index d919bae0..98d95054 100644 --- a/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/IndexedCursor.java +++ b/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/IndexedCursor.java @@ -128,7 +128,7 @@ public static Optional createCursor( IndexedCursor cursor = new IndexedCursor(conn, key, tableIndex, isDuplicate, comparator); cursor.forwardCursor = getCursor(conn, key, tableIndex, isDuplicate, comparator, true); cursor.backwardCursor = getCursor(conn, key, tableIndex, isDuplicate, comparator, false); - if (cursor.forwardCursor.isEmpty() || cursor.backwardCursor.isEmpty()) { + if (!cursor.forwardCursor.isPresent() || !cursor.backwardCursor.isPresent()) { return Optional.empty(); } else { return Optional.of(cursor); @@ -178,14 +178,14 @@ public Optional reloadCursor() { Optional reFetchResult = reFetch(this.conn, this.tableIndex, this.isDuplicate, result); - if (!reFetchResult.isEmpty()) { + if (reFetchResult.isPresent()) { FetchResult r = reFetchResult.get(); newCursor.forwardBuffer.add(r); newCursor.cursorIndex = 0; newCursor.firstFetch = false; } - if (newCursor.forwardCursor.isEmpty() || newCursor.backwardCursor.isEmpty()) { + if (!newCursor.forwardCursor.isPresent() || !newCursor.backwardCursor.isPresent()) { return Optional.empty(); } else { return Optional.of(newCursor); @@ -409,7 +409,7 @@ private Optional fetchPrev(ResultSet cursor) { * return Optional.empty() */ public Optional next() { - if (this.forwardCursor.isEmpty()) { + if (!this.forwardCursor.isPresent()) { return Optional.empty(); } ResultSet cursor = this.forwardCursor.get(); @@ -458,7 +458,7 @@ public Optional next() { * return Optional.empty() */ public Optional prev() { - if (this.backwardCursor.isEmpty()) { + if (!this.backwardCursor.isPresent()) { return Optional.empty(); } ResultSet cursor = this.backwardCursor.get(); @@ -524,7 +524,7 @@ private static Optional getCursor( boolean forward) { final Optional optionalCompOperator = getCompOperator(comparator, forward); - if (optionalCompOperator.isEmpty()) { + if (!optionalCompOperator.isPresent()) { return Optional.empty(); } @@ -617,7 +617,7 @@ private Optional getCursorForFirstLast( public boolean moveToFirst() { Optional cursor = getCursorForFirstLast(this.tableIndex, this.isDuplicate, CursorReadOption.FIRST); - if (cursor.isEmpty()) { + if (!cursor.isPresent()) { return false; } this.forwardCursor = cursor; @@ -630,7 +630,7 @@ public boolean moveToFirst() { public boolean moveToLast() { Optional cursor = getCursorForFirstLast(this.tableIndex, this.isDuplicate, CursorReadOption.LAST); - if (cursor.isEmpty()) { + if (!cursor.isPresent()) { return false; } this.backwardCursor = cursor; From 41d5d81c2e8805e08f77d315cf1b9eb6fe7e5936 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Tue, 7 Nov 2023 20:01:16 +0900 Subject: [PATCH 2/8] [Settings]: Specify the file encoding for gradle builds --- libcobj/app/build.gradle.kts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libcobj/app/build.gradle.kts b/libcobj/app/build.gradle.kts index 45553248..23e962e5 100644 --- a/libcobj/app/build.gradle.kts +++ b/libcobj/app/build.gradle.kts @@ -7,17 +7,29 @@ plugins { id("com.github.sherter.google-java-format") version "0.9" id("maven-publish") pmd - id("com.github.spotbugs") version "6.0.0-rc.2" + //id("com.github.spotbugs") version "6.0.0-rc.2" } repositories { mavenCentral() } +tasks { + javadoc { + options.encoding = "UTF-8" + } + compileJava { + options.encoding = "UTF-8" + } + compileTestJava { + options.encoding = "UTF-8" + } +} + dependencies { implementation("com.google.guava:guava:31.1-jre") implementation("org.xerial:sqlite-jdbc:3.30.1") - spotbugs("com.github.spotbugs:spotbugs:4.8.0") + //spotbugs("com.github.spotbugs:spotbugs:4.8.0") } java { From 581d96238bcb7831bf6ee49d8ca1056075ac525f Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Tue, 7 Nov 2023 20:15:58 +0900 Subject: [PATCH 3/8] [Fix]: fix cobj.c --- cobj/cobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cobj/cobj.c b/cobj/cobj.c index d5fbfe5e..9ca9e491 100644 --- a/cobj/cobj.c +++ b/cobj/cobj.c @@ -1732,7 +1732,7 @@ static int process_compile(struct filename *fn) { } sprintf( buff, - "cd %s && jar --create --main-class=%s --file=%s.jar %s/*.class", + "cd %s && jar -c -e %s -f %s.jar %s/*.class", output_name_a, *program_id, *program_id, package_dir); ret = process(buff); if (ret) { @@ -1992,7 +1992,7 @@ int process_build_single_jar() { package_dir = "."; } - sprintf(buff, "cd %s && jar --create --file=%s %s/*.class", output_name_a, + sprintf(buff, "cd %s && jar -c -f %s %s/*.class", output_name_a, cb_single_jar_name, package_dir); ret = process(buff); sprintf(buff, "rm -f %s/%s/*.class #aaa", output_name_a, package_dir); From 59d985c5c9761666866004969fbd5780e53027a8 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Tue, 7 Nov 2023 20:33:28 +0900 Subject: [PATCH 4/8] [Update]: change the jdk version 11 --- .github/workflows/cicd.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/test-nist.yml | 2 +- .github/workflows/test-other.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 724725f9..9c830385 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '8' + java-version: '11' - name: Install dependencies on Ubuntu 22.04 if: matrix.os == 'ubuntu:22.04' diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 550cbe58..e924d753 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '8' + java-version: '11' - name: Install dependencies on Ubuntu 22.04 run: | diff --git a/.github/workflows/test-nist.yml b/.github/workflows/test-nist.yml index 242be95b..e40e96fd 100644 --- a/.github/workflows/test-nist.yml +++ b/.github/workflows/test-nist.yml @@ -32,7 +32,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '8' + java-version: '11' - name: Install dependencies on Ubuntu 22.04 if: matrix.os == 'ubuntu:22.04' diff --git a/.github/workflows/test-other.yml b/.github/workflows/test-other.yml index 1bc02118..55a632c5 100644 --- a/.github/workflows/test-other.yml +++ b/.github/workflows/test-other.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '8' + java-version: '11' - name: Install dependencies on Ubuntu 22.04 if: matrix.os == 'ubuntu:22.04' From 572a85f20052276a0c4c0115c35def8f12423250 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Tue, 7 Nov 2023 20:38:20 +0900 Subject: [PATCH 5/8] [Update]: Introduce the spotbugs plugin again --- libcobj/app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcobj/app/build.gradle.kts b/libcobj/app/build.gradle.kts index 23e962e5..3245ab2a 100644 --- a/libcobj/app/build.gradle.kts +++ b/libcobj/app/build.gradle.kts @@ -7,7 +7,7 @@ plugins { id("com.github.sherter.google-java-format") version "0.9" id("maven-publish") pmd - //id("com.github.spotbugs") version "6.0.0-rc.2" + id("com.github.spotbugs") version "6.0.0-rc.2" } repositories { @@ -29,7 +29,7 @@ tasks { dependencies { implementation("com.google.guava:guava:31.1-jre") implementation("org.xerial:sqlite-jdbc:3.30.1") - //spotbugs("com.github.spotbugs:spotbugs:4.8.0") + spotbugs("com.github.spotbugs:spotbugs:4.8.0") } java { From 4db887d498fdc25aef0515b483bc3637d1e9d7d7 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Tue, 7 Nov 2023 20:40:05 +0900 Subject: [PATCH 6/8] [Remove]: remove a workflow file that create a coverage report --- .github/workflows/coverage.yml | 98 ---------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index e924d753..00000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: Make a coverate report - -on: - workflow_dispatch: - -env: - CLASSPATH: ":/usr/lib/opensourcecobol4j/libcobj.jar" - -jobs: - run-tests: - runs-on: ubuntu-latest - steps: - - - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '11' - - - name: Install dependencies on Ubuntu 22.04 - run: | - sudo apt update -y - sudo apt install -y default-jdk build-essential bison flex gettext texinfo automake autoconf gcovr - - - name: Checkout opensource COBOL 4J - uses: actions/checkout@v3 - - - name: Install opensource COBOL 4J - run: | - ./configure CFLAGS='-fprofile-arcs -ftest-coverage' --prefix=/usr/ - make - sudo make install - - #- name: Run tests "command-line-options" - # run: | - # cd tests/ - # ./command-line-options - - #- name: Run tests "misc" - # run: | - # cd tests/ - # ./misc - - #- name: Run tests "data-rep" - # run: | - # cd tests/ - # ./data-rep - - #- name: Run tests "i18n_sjis" - # run: | - # cd tests/ - # ./i18n_sjis - - #- name: Run tests "jp-compat" - # run: | - # cd tests/ - # ./jp-compat - - #- name: Run tests "run" - # run: | - # cd tests/ - # ./run - - #- name: Run tests "syntax" - # run: | - # cd tests/ - # ./syntax - - #- name: Run NIST test - # run: | - # cd tests/cobol85 - # make test - - #- name: Run Extra NIST test - # run: | - # cd tests/cobol85 - # make test-extra - - # #- name: Run tests "i18n_utf8" - # # run: | - # # ./configure --prefix=/usr/ --with-vbisam --enable-utf8 - # # make - # # make install - # # ./i18n_utf8 || true - # # cd ../ - - #- name: Make a coverage report - # run: | - # cd cobj - # gcov -l *.gcda - # gcovr -r . --html -o report.html - # mkdir coverage-report - # cp *.gcno *.gcda *.gcov report.html coverage-report - - #- name: Archive a coverage report - # uses: actions/upload-artifact@v3 - # with: - # name: code-coverage-report - # path: cobj/coverage-report/ \ No newline at end of file From 068d85bff2dd027b829bc299c82c5d7e4cb210be Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Tue, 7 Nov 2023 20:45:25 +0900 Subject: [PATCH 7/8] [Fix]: fix the CI job that runs static analysis --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 9c830385..4f67db52 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -95,7 +95,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '8' + java-version: '11' - name: Install static analysis tools run: | From df1131c748d6fc8c08292537fb349db9156ae317 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Tue, 7 Nov 2023 20:59:15 +0900 Subject: [PATCH 8/8] [Fix]: revert cobj/cobj.c --- cobj/cobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cobj/cobj.c b/cobj/cobj.c index 9ca9e491..d5fbfe5e 100644 --- a/cobj/cobj.c +++ b/cobj/cobj.c @@ -1732,7 +1732,7 @@ static int process_compile(struct filename *fn) { } sprintf( buff, - "cd %s && jar -c -e %s -f %s.jar %s/*.class", + "cd %s && jar --create --main-class=%s --file=%s.jar %s/*.class", output_name_a, *program_id, *program_id, package_dir); ret = process(buff); if (ret) { @@ -1992,7 +1992,7 @@ int process_build_single_jar() { package_dir = "."; } - sprintf(buff, "cd %s && jar -c -f %s %s/*.class", output_name_a, + sprintf(buff, "cd %s && jar --create --file=%s %s/*.class", output_name_a, cb_single_jar_name, package_dir); ret = process(buff); sprintf(buff, "rm -f %s/%s/*.class #aaa", output_name_a, package_dir);