From a1b01430eb18e96a6e28af491d8d287c4e16d5c7 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 26 Apr 2024 17:01:42 -0400 Subject: [PATCH 001/114] Use macos-13 for Java 8 --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index fd54b482a0..4668367a18 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -27,7 +27,7 @@ jobs: continue-on-error: ${{ matrix.experimental }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-13] java: [ 8, 11, 17, 21 ] experimental: [false] # include: From 77353bb0344a8d98a5b8f6ccb2704823417acd0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:01:56 -0400 Subject: [PATCH 002/114] Bump github/codeql-action from 3.25.1 to 3.25.3 (#305) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.1 to 3.25.3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/c7f9125735019aa87cfc361530512d50ea439c71...d39d31e687223d841ef683f52467bd88e9b21c14) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0a59457faa..122447377b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@c7f9125735019aa87cfc361530512d50ea439c71 # v3.25.1 + uses: github/codeql-action/init@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@c7f9125735019aa87cfc361530512d50ea439c71 # v3.25.1 + uses: github/codeql-action/autobuild@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@c7f9125735019aa87cfc361530512d50ea439c71 # v3.25.1 + uses: github/codeql-action/analyze@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index b398ee5964..6e46f25a2b 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@c7f9125735019aa87cfc361530512d50ea439c71 # 3.25.1 + uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # 3.25.3 with: sarif_file: results.sarif From 0d8d454875313342a6d97441d78e11839057c3cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:02:11 -0400 Subject: [PATCH 003/114] Bump actions/checkout from 4.1.3 to 4.1.4 (#306) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.3 to 4.1.4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/1d96c772d19495a3b5c517cd2bc0cb401ea0529f...0ad4b8fadaa221de15dcec353f45205ec38ea70b) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/maven.yml | 2 +- .github/workflows/scorecards-analysis.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 122447377b..0a7a3cfe8e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ef257b7528..7670689d9f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -29,7 +29,7 @@ jobs: java: [ 8, 11 ] steps: - - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4668367a18..ea3bdbf9b2 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Prepare git run: git config --global core.autocrlf false - - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 6e46f25a2b..defe570b3c 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -40,7 +40,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: persist-credentials: false From cdd1c5ec0375ea35e142a500239d43d2b28d598b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:02:22 -0400 Subject: [PATCH 004/114] Bump actions/upload-artifact from 4.3.2 to 4.3.3 (#307) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.2 to 4.3.3. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/1746f4ab65b179e0ea60a494b83293b640dd5bba...65462800fd760344b1a7b4382951275a0abb4808) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/scorecards-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index defe570b3c..e7d0b2d88f 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -57,7 +57,7 @@ jobs: publish_results: true - name: "Upload artifact" - uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: SARIF file path: results.sarif From 6514ab13c9f1357099ace54588faecdc993374d5 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 27 Apr 2024 12:58:22 +0000 Subject: [PATCH 005/114] Bump to next development version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ed4484eca9..6011b075af 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ org.apache.bcel bcel jar - 6.9.0 + 6.9.1-SNAPSHOT Apache Commons BCEL Apache Commons Bytecode Engineering Library @@ -43,7 +43,7 @@ UTF-8 UTF-8 - 2024-04-21T16:51:47Z + 2024-04-27T12:58:11Z 1.8 1.8 bcel From 03ffae7a7a0a7827dd08e097b0de8523460185c6 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 27 Apr 2024 09:39:36 -0400 Subject: [PATCH 006/114] Add section for the next release --- src/changes/changes.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index acc9b8b6ca..386f1062d4 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -59,6 +59,11 @@ The type attribute can be add,update,fix,remove. Defining changes.version allows one to create the RN without first removing the SNAPSHOT suffix. --> + + + + + Add Support for Java 16 records #290. From 4770d2ceba5a722e1a1a5ae840b80879d765dba6 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 27 Apr 2024 10:00:47 -0400 Subject: [PATCH 007/114] Put title and version on the same line --- RELEASE-NOTES.txt | 44 ++++++++++++------------------------ src/changes/release-notes.vm | 3 +-- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 6677e03765..d9b16ea375 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,5 +1,4 @@ -Apache Commons BCEL -Version 6.9.0 +Apache Commons BCEL Version 6.9.0 RELEASE NOTES @@ -87,8 +86,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.8.2 +Apache Commons BCEL Version 6.8.2 RELEASE NOTES @@ -144,8 +142,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.8.1 +Apache Commons BCEL Version 6.8.1 RELEASE NOTES @@ -213,8 +210,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.8.0 +Apache Commons BCEL Version 6.8.0 RELEASE NOTES @@ -302,8 +298,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.7.0 +Apache Commons BCEL Version 6.7.0 RELEASE NOTES @@ -415,8 +410,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.6.1 +Apache Commons BCEL Version 6.6.1 RELEASE NOTES @@ -475,8 +469,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.6.0 +Apache Commons BCEL Version 6.6.0 RELEASE NOTES @@ -606,8 +599,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.5.0 +Apache Commons BCEL Version 6.5.0 RELEASE NOTES @@ -680,8 +672,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.4.1 +Apache Commons BCEL Version 6.4.1 RELEASE NOTES @@ -737,8 +728,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.4.0 +Apache Commons BCEL Version 6.4.0 RELEASE NOTES @@ -812,8 +802,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.3.1 +Apache Commons BCEL Version 6.3.1 RELEASE NOTES @@ -863,8 +852,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.3 +Apache Commons BCEL Version 6.3 RELEASE NOTES @@ -921,8 +909,7 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL -Version 6.2 +Apache Commons BCEL Version 6.2 RELEASE NOTES @@ -968,9 +955,8 @@ The Apache Commons Team ----------------------------------------------------------------------------- -Apache Commons BCEL - Version 6.1 - RELEASE NOTES +Apache Commons BCEL Version 6.1 +RELEASE NOTES Introduction diff --git a/src/changes/release-notes.vm b/src/changes/release-notes.vm index ae8ae40b00..ed53833d3d 100644 --- a/src/changes/release-notes.vm +++ b/src/changes/release-notes.vm @@ -15,8 +15,7 @@ ## specific language governing permissions and limitations ## under the License. ## -${project.name} -Version ${version} +${project.name} Version ${version} RELEASE NOTES From dfd59091d08aa1b86f27d0766161750faa0a81f1 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Wed, 1 May 2024 10:07:54 -0400 Subject: [PATCH 008/114] Use SystemProperties instead of a magic string lookup --- src/main/java/org/apache/bcel/util/ClassPath.java | 7 ++++--- src/test/java/org/apache/bcel/PerformanceTest.java | 3 ++- src/test/java/org/apache/bcel/util/BCELifierTestCase.java | 3 ++- .../org/apache/bcel/verifier/VerifierMainTestCase.java | 3 ++- .../java/org/apache/bcel/verifier/VerifierTestCase.java | 3 ++- .../org/apache/bcel/verifier/VerifyBadClassesTestCase.java | 3 ++- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/bcel/util/ClassPath.java b/src/main/java/org/apache/bcel/util/ClassPath.java index e48a63222e..0f1c342fc0 100644 --- a/src/main/java/org/apache/bcel/util/ClassPath.java +++ b/src/main/java/org/apache/bcel/util/ClassPath.java @@ -42,6 +42,7 @@ import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Utility; +import org.apache.commons.lang3.SystemProperties; /** * Loads class files from the CLASSPATH. Inspired by sun.tools.ClassPath. @@ -466,14 +467,14 @@ private static void addJdkModules(final String javaHome, final List list */ // @since 6.0 no longer final public static String getClassPath() { - final String classPathProp = System.getProperty("java.class.path"); + final String classPathProp = SystemProperties.getJavaClassPath(); final String bootClassPathProp = System.getProperty("sun.boot.class.path"); - final String extDirs = System.getProperty("java.ext.dirs"); + final String extDirs = SystemProperties.getJavaExtDirs(); // System.out.println("java.version = " + System.getProperty("java.version")); // System.out.println("java.class.path = " + classPathProp); // System.out.println("sun.boot.class.path=" + bootClassPathProp); // System.out.println("java.ext.dirs=" + extDirs); - final String javaHome = System.getProperty("java.home"); + final String javaHome = SystemProperties.getJavaHome(); final List list = new ArrayList<>(); // Starting in JRE 9, .class files are in the modules directory. Add them to the path. diff --git a/src/test/java/org/apache/bcel/PerformanceTest.java b/src/test/java/org/apache/bcel/PerformanceTest.java index 7191d6d44b..7b7dff4bbd 100644 --- a/src/test/java/org/apache/bcel/PerformanceTest.java +++ b/src/test/java/org/apache/bcel/PerformanceTest.java @@ -34,6 +34,7 @@ import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.MethodGen; +import org.apache.commons.lang3.SystemProperties; import org.junit.jupiter.api.Test; public final class PerformanceTest { @@ -130,7 +131,7 @@ private static void test(final File lib) throws IOException { @Test public void testPerformance() { - final File javaLib = new File(System.getProperty("java.home"), "lib"); + final File javaLib = new File(SystemProperties.getJavaHome(), "lib"); javaLib.listFiles(file -> { if (file.getName().endsWith(".jar")) { try { diff --git a/src/test/java/org/apache/bcel/util/BCELifierTestCase.java b/src/test/java/org/apache/bcel/util/BCELifierTestCase.java index 9e66445464..7467104bb5 100644 --- a/src/test/java/org/apache/bcel/util/BCELifierTestCase.java +++ b/src/test/java/org/apache/bcel/util/BCELifierTestCase.java @@ -35,6 +35,7 @@ import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Utility; import org.apache.bcel.generic.BinaryOpCreator; +import org.apache.commons.lang3.SystemProperties; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -42,7 +43,7 @@ public class BCELifierTestCase extends AbstractTestCase { private static final String EOL = System.lineSeparator(); - public static final String CLASSPATH = "." + File.pathSeparator + System.getProperty("java.class.path"); + public static final String CLASSPATH = "." + File.pathSeparator + SystemProperties.getJavaClassPath(); // Canonicalise the javap output so it compares better private String canonHashRef(String input) { diff --git a/src/test/java/org/apache/bcel/verifier/VerifierMainTestCase.java b/src/test/java/org/apache/bcel/verifier/VerifierMainTestCase.java index f1b4b4ff6d..76495b8d22 100644 --- a/src/test/java/org/apache/bcel/verifier/VerifierMainTestCase.java +++ b/src/test/java/org/apache/bcel/verifier/VerifierMainTestCase.java @@ -36,6 +36,7 @@ import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.SWAP; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.SystemProperties; import org.eclipse.jdt.internal.compiler.batch.Main; import org.junit.jupiter.api.Test; @@ -52,7 +53,7 @@ public void testSWAP() throws Exception { args.add(javaAgent.replace("jacoco.exec", "jacoco_org.apache.bcel.data.SWAP.exec")); } args.add("-cp"); - args.add(System.getProperty("java.class.path")); + args.add(SystemProperties.getJavaClassPath()); args.add("org.apache.bcel.verifier.Verifier"); args.add("org/apache/bcel/data/SWAP.class"); final ProcessBuilder pb = new ProcessBuilder(args); diff --git a/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java b/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java index 314fb6b6d6..3496191a63 100644 --- a/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java +++ b/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java @@ -38,6 +38,7 @@ import org.apache.bcel.verifier.input.StaticFieldVerifierChildClass; import org.apache.bcel.verifier.statics.StringRepresentation; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.SystemProperties; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledForJreRange; @@ -89,7 +90,7 @@ private static void testJarFile(final File file, final String... excludes) throw } private static void testNestHostWithJavaVersion(final String className) throws ClassNotFoundException { - final String version = System.getProperty("java.version"); + final String version = SystemProperties.getJavaVersion(); assertNotNull(version); try { testDefaultMethodValidation(className); diff --git a/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java b/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java index 46af8c80fd..4d46730ea7 100644 --- a/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java +++ b/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java @@ -35,6 +35,7 @@ import org.apache.commons.exec.ExecuteWatchdog; import org.apache.commons.exec.PumpStreamHandler; import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.SystemProperties; import org.junit.jupiter.api.Test; /** @@ -49,7 +50,7 @@ private List buildVerifyCommand(final String className, final String tes command.add("-ea"); command.add("-classpath"); - command.add(System.getProperty("java.class.path") + ":" + testDir); + command.add(SystemProperties.getJavaClassPath() + ":" + testDir); command.add("org.apache.bcel.verifier.Verifier"); command.add(className); From 2d8133b4ccf0fb143c0a2d1ec6e84d1a702e8b7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 May 2024 15:56:29 -0400 Subject: [PATCH 009/114] Bump codecov/codecov-action from 4.3.0 to 4.3.1 (#308) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.3.0 to 4.3.1. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/84508663e988701840491b86de86b666e8a86bed...5ecb98a3c6b747ed38dc09f787459979aebb39be) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 7670689d9f..5d732703fc 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -47,6 +47,6 @@ jobs: run: mvn --show-version --batch-mode --no-transfer-progress install jacoco:report -DdataFile=jacoco_jdk${{ matrix.java }}.exec - name: Upload coverage to Codecov - uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4.3.0 + uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # v4.3.1 with: files: ./target/site/jacoco/jacoco.xml From beebb72673e0c70bf7236211ff913335cbe928d8 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 4 May 2024 13:48:49 -0400 Subject: [PATCH 010/114] Use Checkstyle WhitespaceAfter --- src/conf/checkstyle.xml | 10 --------- src/main/java/org/apache/bcel/Constants.java | 2 +- .../org/apache/bcel/classfile/Signature.java | 8 +++---- .../bcel/generic/AnnotationEntryGen.java | 4 ++-- .../bcel/generic/ClassElementValueGen.java | 4 ++-- .../bcel/generic/ElementValuePairGen.java | 4 ++-- .../bcel/generic/EnumElementValueGen.java | 22 +++++++++---------- .../apache/bcel/generic/InstructionList.java | 2 +- .../org/apache/bcel/util/BCELFactory.java | 2 +- .../apache/bcel/classfile/RecordTestCase.java | 15 ++++++------- .../bcel/classfile/UtilityTestCase.java | 2 +- .../bcel/generic/BranchHandleTestCase.java | 6 ++--- .../generic/InstructionHandleTestCase.java | 6 ++--- 13 files changed, 37 insertions(+), 50 deletions(-) diff --git a/src/conf/checkstyle.xml b/src/conf/checkstyle.xml index 21cee04dbc..581c1dee71 100644 --- a/src/conf/checkstyle.xml +++ b/src/conf/checkstyle.xml @@ -103,17 +103,7 @@ limitations under the License. - - diff --git a/src/main/java/org/apache/bcel/Constants.java b/src/main/java/org/apache/bcel/Constants.java index e3e733471b..824073b982 100644 --- a/src/main/java/org/apache/bcel/Constants.java +++ b/src/main/java/org/apache/bcel/Constants.java @@ -2415,7 +2415,7 @@ public interface Constants { byte ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS = 15; byte ATTR_ANNOTATION_DEFAULT = 16; - short KNOWN_ATTRIBUTES = 12;// should be 17 + short KNOWN_ATTRIBUTES = 12; // should be 17 // TODO: mutable public array!! String[] ATTRIBUTE_NAMES = {"SourceFile", "ConstantValue", "Code", "Exceptions", "LineNumberTable", "LocalVariableTable", "InnerClasses", "Synthetic", diff --git a/src/main/java/org/apache/bcel/classfile/Signature.java b/src/main/java/org/apache/bcel/classfile/Signature.java index f36c08ad86..24ece2869d 100644 --- a/src/main/java/org/apache/bcel/classfile/Signature.java +++ b/src/main/java/org/apache/bcel/classfile/Signature.java @@ -105,7 +105,7 @@ private static void matchIdent(final MyByteArrayInputStream in, final StringBuil if ((ch = in.read()) == -1) { throw new IllegalArgumentException("Illegal signature: " + in.getData() + " no ident, reaching EOF"); } - // System.out.println("return from ident:" + (char)ch); + // System.out.println("return from ident:" + (char) ch); if (!identStart(ch)) { final StringBuilder buf2 = new StringBuilder(); int count = 1; @@ -123,7 +123,7 @@ private static void matchIdent(final MyByteArrayInputStream in, final StringBuil buf.append(buf2); ch = in.read(); in.unread(); - // System.out.println("so far:" + buf2 + ":next:" +(char)ch); + // System.out.println("so far:" + buf2 + ":next:" +(char) ch); } else { for (int i = 0; i < count; i++) { in.unread(); @@ -136,10 +136,10 @@ private static void matchIdent(final MyByteArrayInputStream in, final StringBuil do { buf2.append((char) ch); ch = in.read(); - // System.out.println("within ident:"+ (char)ch); + // System.out.println("within ident:"+ (char) ch); } while (ch != -1 && (Character.isJavaIdentifierPart((char) ch) || ch == '/')); buf.append(Utility.pathToPackage(buf2.toString())); - // System.out.println("regular return ident:"+ (char)ch + ":" + buf2); + // System.out.println("regular return ident:"+ (char) ch + ":" + buf2); if (ch != -1) { in.unread(); } diff --git a/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java b/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java index e0e04ec4aa..30eeaead6b 100644 --- a/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java +++ b/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java @@ -280,12 +280,12 @@ public int getTypeIndex() { } public final String getTypeName() { - return getTypeSignature();// BCELBUG: Should I use this instead? + return getTypeSignature(); // BCELBUG: Should I use this instead? // Utility.signatureToString(getTypeSignature()); } public final String getTypeSignature() { - // ConstantClass c = (ConstantClass)cpool.getConstant(typeIndex); + // ConstantClass c = (ConstantClass) cpool.getConstant(typeIndex); final ConstantUtf8 utf8 = (ConstantUtf8) cpool.getConstant(typeIndex/* c.getNameIndex() */); return utf8.getBytes(); } diff --git a/src/main/java/org/apache/bcel/generic/ClassElementValueGen.java b/src/main/java/org/apache/bcel/generic/ClassElementValueGen.java index bf2538b8f6..e02366ffd1 100644 --- a/src/main/java/org/apache/bcel/generic/ClassElementValueGen.java +++ b/src/main/java/org/apache/bcel/generic/ClassElementValueGen.java @@ -62,9 +62,9 @@ public void dump(final DataOutputStream dos) throws IOException { public String getClassString() { final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx); return cu8.getBytes(); - // ConstantClass c = (ConstantClass)getConstantPool().getConstant(idx); + // ConstantClass c = (ConstantClass) getConstantPool().getConstant(idx); // ConstantUtf8 utf8 = - // (ConstantUtf8)getConstantPool().getConstant(c.getNameIndex()); + // (ConstantUtf8) getConstantPool().getConstant(c.getNameIndex()); // return utf8.getBytes(); } diff --git a/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java b/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java index 6722d3c430..96be7a74c9 100644 --- a/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java +++ b/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java @@ -39,7 +39,7 @@ public ElementValuePairGen(final ElementValuePair nvp, final ConstantPoolGen cpo // Could assert nvp.getNameString() points to the same thing as // constantPoolGen.getConstant(nvp.getNameIndex()) // if - // (!nvp.getNameString().equals(((ConstantUtf8)constantPoolGen.getConstant(nvp.getNameIndex())).getBytes())) + // (!nvp.getNameString().equals(((ConstantUtf8) constantPoolGen.getConstant(nvp.getNameIndex())).getBytes())) // { // throw new IllegalArgumentException("envp buggered"); // } @@ -81,7 +81,7 @@ public int getNameIndex() { } public final String getNameString() { - // ConstantString cu8 = (ConstantString)constantPoolGen.getConstant(nameIdx); + // ConstantString cu8 = (ConstantString) constantPoolGen.getConstant(nameIdx); return ((ConstantUtf8) constantPoolGen.getConstant(nameIdx)).getBytes(); } diff --git a/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java b/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java index ef1f5f4c90..954a739aba 100644 --- a/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java +++ b/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java @@ -35,10 +35,8 @@ public class EnumElementValueGen extends ElementValueGen { public EnumElementValueGen(final EnumElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) { super(ENUM_CONSTANT, cpool); if (copyPoolEntries) { - typeIdx = cpool.addUtf8(value.getEnumTypeString());// was - // addClass(value.getEnumTypeString()); - valueIdx = cpool.addUtf8(value.getEnumValueString()); // was - // addString(value.getEnumValueString()); + typeIdx = cpool.addUtf8(value.getEnumTypeString()); // was addClass(value.getEnumTypeString()); + valueIdx = cpool.addUtf8(value.getEnumValueString()); // was addString(value.getEnumValueString()); } else { typeIdx = value.getTypeIndex(); valueIdx = value.getValueIndex(); @@ -60,8 +58,8 @@ protected EnumElementValueGen(final int typeIdx, final int valueIdx, final Const public EnumElementValueGen(final ObjectType t, final String value, final ConstantPoolGen cpool) { super(ElementValueGen.ENUM_CONSTANT, cpool); - typeIdx = cpool.addUtf8(t.getSignature());// was addClass(t); - valueIdx = cpool.addUtf8(value);// was addString(value); + typeIdx = cpool.addUtf8(t.getSignature()); // was addClass(t); + valueIdx = cpool.addUtf8(value); // was addString(value); } @Override @@ -85,9 +83,9 @@ public ElementValue getElementValue() { public String getEnumTypeString() { // Constant cc = getConstantPool().getConstant(typeIdx); // ConstantClass cu8 = - // (ConstantClass)getConstantPool().getConstant(typeIdx); + // (ConstantClass) getConstantPool().getConstant(typeIdx); // return - // ((ConstantUtf8)getConstantPool().getConstant(cu8.getNameIndex())).getBytes(); + // ((ConstantUtf8) getConstantPool().getConstant(cu8.getNameIndex())).getBytes(); return ((ConstantUtf8) getConstantPool().getConstant(typeIdx)).getBytes(); // return Utility.signatureToString(cu8.getBytes()); } @@ -95,9 +93,9 @@ public String getEnumTypeString() { public String getEnumValueString() { return ((ConstantUtf8) getConstantPool().getConstant(valueIdx)).getBytes(); // ConstantString cu8 = - // (ConstantString)getConstantPool().getConstant(valueIdx); + // (ConstantString) getConstantPool().getConstant(valueIdx); // return - // ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes(); + // ((ConstantUtf8) getConstantPool().getConstant(cu8.getStringIndex())).getBytes(); } public int getTypeIndex() { @@ -113,8 +111,8 @@ public String stringifyValue() { final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(valueIdx); return cu8.getBytes(); // ConstantString cu8 = - // (ConstantString)getConstantPool().getConstant(valueIdx); + // (ConstantString) getConstantPool().getConstant(valueIdx); // return - // ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes(); + // ((ConstantUtf8) getConstantPool().getConstant(cu8.getStringIndex())).getBytes(); } } diff --git a/src/main/java/org/apache/bcel/generic/InstructionList.java b/src/main/java/org/apache/bcel/generic/InstructionList.java index 0f4340b70f..0f2eece988 100644 --- a/src/main/java/org/apache/bcel/generic/InstructionList.java +++ b/src/main/java/org/apache/bcel/generic/InstructionList.java @@ -1137,7 +1137,7 @@ public void setPositions(final boolean check) { // called by code in other packa index += i.getLength(); } /* - * Pass 2: Expand the variable-length (Branch)Instructions depending on the target offset (short or int) and ensure that + * Pass 2: Expand the variable-length (Branch) Instructions depending on the target offset (short or int) and ensure that * branch targets are within this list. */ for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { diff --git a/src/main/java/org/apache/bcel/util/BCELFactory.java b/src/main/java/org/apache/bcel/util/BCELFactory.java index b00ab70396..e22c6ce304 100644 --- a/src/main/java/org/apache/bcel/util/BCELFactory.java +++ b/src/main/java/org/apache/bcel/util/BCELFactory.java @@ -83,7 +83,7 @@ private void createConstant(final Object value) { if (value instanceof String) { embed = '"' + Utility.convertString(embed) + '"'; } else if (value instanceof Character) { - embed = "(char)0x" + Integer.toHexString(((Character) value).charValue()); + embed = "(char) 0x" + Integer.toHexString(((Character) value).charValue()); } else if (value instanceof Float) { final Float f = (Float) value; if (Float.isNaN(f)) { diff --git a/src/test/java/org/apache/bcel/classfile/RecordTestCase.java b/src/test/java/org/apache/bcel/classfile/RecordTestCase.java index 8056250a7d..62e139ec04 100644 --- a/src/test/java/org/apache/bcel/classfile/RecordTestCase.java +++ b/src/test/java/org/apache/bcel/classfile/RecordTestCase.java @@ -50,8 +50,8 @@ public void recordsCanBeVisited() throws ClassNotFoundException, IOException { final CountingVisitor countVisitor = new CountingVisitor(); final DescendingVisitor desendingVisitor = new DescendingVisitor(clazz, countVisitor); desendingVisitor.visit(); - assertEquals(1,countVisitor.recordCount, "should count one record"); - assertEquals(2,countVisitor.recordComponentCount, "should count two record components"); + assertEquals(1, countVisitor.recordCount, "should count one record"); + assertEquals(2, countVisitor.recordComponentCount, "should count two record components"); } @@ -62,13 +62,13 @@ public void recordsCanBeVisited() throws ClassNotFoundException, IOException { public void testAttributeSerializtion() throws ClassNotFoundException, IOException { final JavaClass clazz = new ClassParser("src/test/resources/record/SimpleRecord.class").parse(); final File tfile = createTestdataFile("SimpleRecord.class"); - final Record recordAttribute = (Record)findAttribute("Record",clazz)[0]; + final Record recordAttribute = (Record) findAttribute("Record", clazz)[0]; clazz.dump(tfile); // Read in the new version and check it is OK final SyntheticRepository repos2 = createRepos("."); final JavaClass clazzFromRepo = repos2.loadClass("SimpleRecord"); assertNotNull(clazzFromRepo); // Use the variable to avoid a warning - final Record recordAttributeFromRepo = (Record)findAttribute("Record",clazzFromRepo)[0]; + final Record recordAttributeFromRepo = (Record) findAttribute("Record", clazzFromRepo)[0]; assertEquals(recordAttribute.toString(), recordAttributeFromRepo.toString(), "Both attributes needs to be equal"); tfile.deleteOnExit(); } @@ -101,20 +101,19 @@ public void testRecordClassSaysItIs() throws ClassNotFoundException, ClassFormat public void testRecordToString() throws ClassNotFoundException, ClassFormatException, IOException { final JavaClass clazz = new ClassParser("src/test/resources/record/SimpleRecord.class").parse(); final Attribute[] attributes = clazz.getAttributes(); - final Record recordAttribute = (Record) findAttribute("Record",clazz)[0]; + final Record recordAttribute = (Record) findAttribute("Record", clazz)[0]; assertEquals(4, attributes.length); assertEquals("SourceFile: SimpleRecord.java", attributes[0].toString()); assertEquals("Record(2):\n" + " RecordComponentInfo(aNumber,I,0):\n" + " RecordComponentInfo(aString,Ljava/lang/String;,1):\n" + " RuntimeVisibleAnnotations:\n" - + " @Ljavax/annotation/Nonnull;" - ,recordAttribute.toString()); + + " @Ljavax/annotation/Nonnull;", recordAttribute.toString()); final RecordComponentInfo firstComponent = recordAttribute.getComponents()[0]; assertEquals(5, firstComponent.getIndex()); assertEquals(6, firstComponent.getDescriptorIndex()); assertEquals(0, firstComponent.getAttributes().length); - assertEquals(recordAttribute.getConstantPool(),firstComponent.getConstantPool()); + assertEquals(recordAttribute.getConstantPool(), firstComponent.getConstantPool()); assertEquals("RecordComponentInfo(aNumber,I,0):", firstComponent.toString()); } diff --git a/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java b/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java index 7d6095d0c2..192c2b5937 100644 --- a/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java +++ b/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java @@ -80,7 +80,7 @@ final class CodeToString { assertTrue(code.contains("33: getfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.a [[I"), code); assertTrue(code.contains("36: invokestatic\tjava.util.Arrays.asList ([Ljava/lang/Object;)Ljava/util/List;"), code); assertTrue(code.contains("39: invokeinterface\tjava.util.List.size ()I1\t0"), code); - assertTrue(code.contains("44: invokevirtual\tjava.io.PrintStream.print (I)V"), code); + assertTrue(code.contains("44: invokevirtual\tjava.io.PrintStream.print "), code); assertTrue(code.contains("47: return"), code); } } diff --git a/src/test/java/org/apache/bcel/generic/BranchHandleTestCase.java b/src/test/java/org/apache/bcel/generic/BranchHandleTestCase.java index 2927bdc455..9d0f879f46 100644 --- a/src/test/java/org/apache/bcel/generic/BranchHandleTestCase.java +++ b/src/test/java/org/apache/bcel/generic/BranchHandleTestCase.java @@ -30,7 +30,7 @@ public void testGetBHnull() { @Test public void testsetInstructionBI() { - final BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null));// have to start with a valid BI + final BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null)); // have to start with a valid BI assertNotNull(bh); bh.setInstruction(new GOTO(null)); assertNotNull(bh); @@ -38,7 +38,7 @@ public void testsetInstructionBI() { @Test public void testsetInstructionnotBI() { - final BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null));// have to start with a valid BI + final BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null)); // have to start with a valid BI assertNotNull(bh); assertThrows(ClassGenException.class, () -> bh.setInstruction(new NOP())); } @@ -46,7 +46,7 @@ public void testsetInstructionnotBI() { // Test that setInstruction only allows BranchInstructions @Test public void testsetInstructionNull() { - final BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null));// have to start with a valid BI + final BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null)); // have to start with a valid BI assertNotNull(bh); assertThrows(ClassGenException.class, () -> bh.setInstruction(null)); } diff --git a/src/test/java/org/apache/bcel/generic/InstructionHandleTestCase.java b/src/test/java/org/apache/bcel/generic/InstructionHandleTestCase.java index 4d79927370..81ea857141 100644 --- a/src/test/java/org/apache/bcel/generic/InstructionHandleTestCase.java +++ b/src/test/java/org/apache/bcel/generic/InstructionHandleTestCase.java @@ -40,7 +40,7 @@ public void testGetIHnull() { @Test public void testsetInstructionI() { - final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI + final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP()); // have to start with a valid non BI assertNotNull(ih); ih.setInstruction(new NOP()); assertNotNull(ih); @@ -48,14 +48,14 @@ public void testsetInstructionI() { @Test public void testsetInstructionnotI() { - final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI + final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP()); // have to start with a valid non BI assertNotNull(ih); assertThrows(ClassGenException.class, () -> ih.setInstruction(new GOTO(null))); } @Test public void testsetInstructionNull() { - final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI + final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP()); // have to start with a valid non BI assertNotNull(ih); assertThrows(ClassGenException.class, () -> ih.setInstruction(null)); } From cfa0016f2c23c74ab8add3ec5fba87afce3edac9 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sun, 5 May 2024 14:42:07 -0400 Subject: [PATCH 011/114] Update Checkstyle DTD version from 1.0 to 1.2 --- src/conf/checkstyle-suppressions.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/checkstyle-suppressions.xml b/src/conf/checkstyle-suppressions.xml index bf3c1e6815..643d511e5d 100644 --- a/src/conf/checkstyle-suppressions.xml +++ b/src/conf/checkstyle-suppressions.xml @@ -17,8 +17,8 @@ limitations under the License. --> + "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" + "https://checkstyle.org/dtds/suppressions_1_2.dtd"> From 0a452920f8ccc2c1592ee0c212079479bae97fe2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 15:46:06 -0400 Subject: [PATCH 012/114] Bump ossf/scorecard-action from 2.3.1 to 2.3.3 (#310) Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.3.1 to 2.3.3. - [Release notes](https://github.com/ossf/scorecard-action/releases) - [Changelog](https://github.com/ossf/scoreccard-action/blob/main/RELEASE.md) - [Commits](https://github.com/ossf/scorecard-action/compare/0864cf19026789058feabb7e87baa5f140aac736...dc50aa9510b46c811795eb24b2f1ba02a914e534) --- updated-dependencies: - dependency-name: ossf/scorecard-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/scorecards-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index e7d0b2d88f..ffb2cfe25c 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -45,7 +45,7 @@ jobs: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # 2.3.1 + uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # 2.3.3 with: results_file: results.sarif results_format: sarif From b5ff918560c97b5d817160d53004b816b6466c35 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 15:46:23 -0400 Subject: [PATCH 013/114] Bump actions/checkout from 4.1.4 to 4.1.5 (#312) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.4 to 4.1.5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/0ad4b8fadaa221de15dcec353f45205ec38ea70b...44c2b7a8a4ea60a981eaca3cf939b5f4305c123b) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/maven.yml | 2 +- .github/workflows/scorecards-analysis.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0a7a3cfe8e..5613b671c8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5d732703fc..40de59ec2a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -29,7 +29,7 @@ jobs: java: [ 8, 11 ] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index ea3bdbf9b2..a7206f8a39 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Prepare git run: git config --global core.autocrlf false - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index ffb2cfe25c..c83f407c2b 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -40,7 +40,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 with: persist-credentials: false From 3797f9d66d073b93233f627fcde42bec7be3d8ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 15:46:34 -0400 Subject: [PATCH 014/114] Bump github/codeql-action from 3.25.3 to 3.25.4 (#311) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.3 to 3.25.4. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/d39d31e687223d841ef683f52467bd88e9b21c14...ccf74c947955fd1cf117aef6a0e4e66191ef6f61) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 5613b671c8..fcc1f01893 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 + uses: github/codeql-action/init@ccf74c947955fd1cf117aef6a0e4e66191ef6f61 # v3.25.4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 + uses: github/codeql-action/autobuild@ccf74c947955fd1cf117aef6a0e4e66191ef6f61 # v3.25.4 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 + uses: github/codeql-action/analyze@ccf74c947955fd1cf117aef6a0e4e66191ef6f61 # v3.25.4 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index c83f407c2b..1b223c06d9 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # 3.25.3 + uses: github/codeql-action/upload-sarif@ccf74c947955fd1cf117aef6a0e4e66191ef6f61 # 3.25.4 with: sarif_file: results.sarif From 6d5afb99a2be92f2512768dc44ec6d742da13c68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 16:38:11 -0400 Subject: [PATCH 015/114] Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.23 to 1.9.24 (#309) Bumps [org.jetbrains.kotlin:kotlin-stdlib](https://github.com/JetBrains/kotlin) from 1.9.23 to 1.9.24. - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.23...v1.9.24) --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-stdlib dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6011b075af..8c9edcb0ab 100644 --- a/pom.xml +++ b/pom.xml @@ -421,7 +421,7 @@ org.jetbrains.kotlin kotlin-stdlib - 1.9.23 + 1.9.24 test From 2ba395392ab489069bfeb9eb2cb9ab9668625e2e Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 10 May 2024 16:39:10 -0400 Subject: [PATCH 016/114] Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.23 to 1.9.24 #309 --- src/changes/changes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 386f1062d4..280a07dbf3 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -63,6 +63,7 @@ The type attribute can be add,update,fix,remove. + Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.23 to 1.9.24 #309. From 0b1f96bdc411e4f7d0d47f7352957f03667e3270 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Thu, 16 May 2024 14:44:29 -0400 Subject: [PATCH 017/114] Show Maven stack traces on errors in GH CI --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a7206f8a39..48b95fff7d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -60,4 +60,4 @@ jobs: distribution: 'temurin' java-version: ${{ matrix.java }} - name: Build with Maven - run: mvn --show-version --batch-mode --no-transfer-progress -DtrimStackTrace=false + run: mvn --errors --show-version --batch-mode --no-transfer-progress -DtrimStackTrace=false From 7338ee7ad6e7988b21b9f7eeae9dc791daea4157 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 16:10:54 -0400 Subject: [PATCH 018/114] Bump codecov/codecov-action from 4.3.1 to 4.4.0 (#317) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.3.1 to 4.4.0. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/5ecb98a3c6b747ed38dc09f787459979aebb39be...6d798873df2b1b8e5846dba6fb86631229fbcb17) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 40de59ec2a..17bd0b36f0 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -47,6 +47,6 @@ jobs: run: mvn --show-version --batch-mode --no-transfer-progress install jacoco:report -DdataFile=jacoco_jdk${{ matrix.java }}.exec - name: Upload coverage to Codecov - uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # v4.3.1 + uses: codecov/codecov-action@6d798873df2b1b8e5846dba6fb86631229fbcb17 # v4.4.0 with: files: ./target/site/jacoco/jacoco.xml From 5dcf9d9bdd161d6faa024aca1658dbb6aed7acc6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 16:11:04 -0400 Subject: [PATCH 019/114] Bump github/codeql-action from 3.25.4 to 3.25.5 (#316) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.4 to 3.25.5. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/ccf74c947955fd1cf117aef6a0e4e66191ef6f61...b7cec7526559c32f1616476ff32d17ba4c59b2d6) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fcc1f01893..7b4b37f54a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@ccf74c947955fd1cf117aef6a0e4e66191ef6f61 # v3.25.4 + uses: github/codeql-action/init@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3.25.5 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@ccf74c947955fd1cf117aef6a0e4e66191ef6f61 # v3.25.4 + uses: github/codeql-action/autobuild@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3.25.5 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@ccf74c947955fd1cf117aef6a0e4e66191ef6f61 # v3.25.4 + uses: github/codeql-action/analyze@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3.25.5 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 1b223c06d9..920276ddb5 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@ccf74c947955fd1cf117aef6a0e4e66191ef6f61 # 3.25.4 + uses: github/codeql-action/upload-sarif@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # 3.25.5 with: sarif_file: results.sarif From 5d4219f8d624cb9081c8cb7e98c80cd8f85d9dbb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 16:11:14 -0400 Subject: [PATCH 020/114] Bump actions/checkout from 4.1.5 to 4.1.6 (#315) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.5 to 4.1.6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/44c2b7a8a4ea60a981eaca3cf939b5f4305c123b...a5ac7e51b41094c92402da3b24376905380afc29) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/maven.yml | 2 +- .github/workflows/scorecards-analysis.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7b4b37f54a..0836f9af72 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 17bd0b36f0..ae023dd548 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -29,7 +29,7 @@ jobs: java: [ 8, 11 ] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 48b95fff7d..602c75aca5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Prepare git run: git config --global core.autocrlf false - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 920276ddb5..87e3fadeaa 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -40,7 +40,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: persist-credentials: false From c3bfb8e59fd1f626f4de6f4bbcda0795af5865cc Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Wed, 22 May 2024 18:19:48 -0400 Subject: [PATCH 021/114] Format nit --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8c9edcb0ab..54e40e7b84 100644 --- a/pom.xml +++ b/pom.xml @@ -68,10 +68,9 @@ 3.25.3 5.14.0 false - true - + true 0.89 0.65 0.70 From b2c3e0eb708fcb3b7e8ed18e16801bc9318cbb6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 15:39:08 -0400 Subject: [PATCH 022/114] Bump github/codeql-action from 3.25.5 to 3.25.6 (#319) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.5 to 3.25.6. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/b7cec7526559c32f1616476ff32d17ba4c59b2d6...9fdb3e49720b44c48891d036bb502feb25684276) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0836f9af72..129bcf117c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3.25.5 + uses: github/codeql-action/init@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3.25.5 + uses: github/codeql-action/autobuild@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3.25.5 + uses: github/codeql-action/analyze@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 87e3fadeaa..4207f4e41c 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # 3.25.5 + uses: github/codeql-action/upload-sarif@9fdb3e49720b44c48891d036bb502feb25684276 # 3.25.6 with: sarif_file: results.sarif From 06b62c1c81c6e76e5fffa02ab4c8bc5f78b54c2c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 15:39:18 -0400 Subject: [PATCH 023/114] Bump codecov/codecov-action from 4.4.0 to 4.4.1 (#320) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.4.0 to 4.4.1. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/6d798873df2b1b8e5846dba6fb86631229fbcb17...125fc84a9a348dbcf27191600683ec096ec9021c) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ae023dd548..ecb9cbf803 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -47,6 +47,6 @@ jobs: run: mvn --show-version --batch-mode --no-transfer-progress install jacoco:report -DdataFile=jacoco_jdk${{ matrix.java }}.exec - name: Upload coverage to Codecov - uses: codecov/codecov-action@6d798873df2b1b8e5846dba6fb86631229fbcb17 # v4.4.0 + uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.4.1 with: files: ./target/site/jacoco/jacoco.xml From c12418276a9c63b216c99cc9aef2d46e23e2ace5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 17:51:41 -0400 Subject: [PATCH 024/114] Bump github/codeql-action from 3.25.6 to 3.25.7 (#321) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.6 to 3.25.7. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/9fdb3e49720b44c48891d036bb502feb25684276...f079b8493333aace61c81488f8bd40919487bd9f) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 129bcf117c..f8675975eb 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6 + uses: github/codeql-action/init@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6 + uses: github/codeql-action/autobuild@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6 + uses: github/codeql-action/analyze@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 4207f4e41c..adca8eb5c0 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@9fdb3e49720b44c48891d036bb502feb25684276 # 3.25.6 + uses: github/codeql-action/upload-sarif@f079b8493333aace61c81488f8bd40919487bd9f # 3.25.7 with: sarif_file: results.sarif From 9e5bf69ce2594cc9b55a5fade32e1fd2610cef9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 17:52:36 -0400 Subject: [PATCH 025/114] Bump org.assertj:assertj-core from 3.25.3 to 3.26.0 (#322) Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.25.3 to 3.26.0. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.25.3...assertj-build-3.26.0) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 54e40e7b84..c1371197e9 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ BCEL 12314220 4.11.0 - 3.25.3 + 3.26.0 5.14.0 false From b970a5b5c62802028176c8378f5e9c98b2f42d09 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 31 May 2024 17:53:10 -0400 Subject: [PATCH 026/114] Bump org.assertj:assertj-core from 3.25.3 to 3.26.0 #322 --- src/changes/changes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 280a07dbf3..29d0801f1a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -64,6 +64,7 @@ The type attribute can be add,update,fix,remove. Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.23 to 1.9.24 #309. + Bump org.assertj:assertj-core from 3.25.3 to 3.26.0 #322. From 0d5ac71de88876194db8de64a083ec0799995d2a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 17:53:24 -0400 Subject: [PATCH 027/114] Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.24 to 2.0.0 (#318) Bumps [org.jetbrains.kotlin:kotlin-stdlib](https://github.com/JetBrains/kotlin) from 1.9.24 to 2.0.0. - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v2.0.0/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.24...v2.0.0) --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-stdlib dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c1371197e9..84e57a5b71 100644 --- a/pom.xml +++ b/pom.xml @@ -420,7 +420,7 @@ org.jetbrains.kotlin kotlin-stdlib - 1.9.24 + 2.0.0 test From 745f88fc94c137f02349a6ff529302faee7d9187 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 31 May 2024 17:54:24 -0400 Subject: [PATCH 028/114] Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.24 to 2.0.0 #318 --- src/changes/changes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 29d0801f1a..7d2727d953 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -63,8 +63,8 @@ The type attribute can be add,update,fix,remove. - Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.23 to 1.9.24 #309. Bump org.assertj:assertj-core from 3.25.3 to 3.26.0 #322. + Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.23 to 2.0.0 #309, #318. From e622158066d93854b515c840f62498274457eb3e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:59:37 -0400 Subject: [PATCH 029/114] Bump github/codeql-action from 3.25.7 to 3.25.8 (#323) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.7 to 3.25.8. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/f079b8493333aace61c81488f8bd40919487bd9f...2e230e8fe0ad3a14a340ad0815ddb96d599d2aff) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f8675975eb..ea181e1686 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 + uses: github/codeql-action/init@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 + uses: github/codeql-action/autobuild@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 + uses: github/codeql-action/analyze@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index adca8eb5c0..2f3af8b18e 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@f079b8493333aace61c81488f8bd40919487bd9f # 3.25.7 + uses: github/codeql-action/upload-sarif@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # 3.25.8 with: sarif_file: results.sarif From 3f5904c93098dba5fae588b20a015cdb2322db45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:00:34 -0400 Subject: [PATCH 030/114] Bump codecov/codecov-action from 4.4.1 to 4.5.0 (#327) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.4.1 to 4.5.0. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/125fc84a9a348dbcf27191600683ec096ec9021c...e28ff129e5465c2c0dcc6f003fc735cb6ae0c673) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ecb9cbf803..897fe88bb9 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -47,6 +47,6 @@ jobs: run: mvn --show-version --batch-mode --no-transfer-progress install jacoco:report -DdataFile=jacoco_jdk${{ matrix.java }}.exec - name: Upload coverage to Codecov - uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.4.1 + uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 with: files: ./target/site/jacoco/jacoco.xml From 9816721aba004ee32dc57070a2ecf52b67bb5159 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:00:46 -0400 Subject: [PATCH 031/114] Bump github/codeql-action from 3.25.8 to 3.25.10 (#328) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.8 to 3.25.10. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/2e230e8fe0ad3a14a340ad0815ddb96d599d2aff...23acc5c183826b7a8a97bce3cecc52db901f8251) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index ea181e1686..e511243b32 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 + uses: github/codeql-action/init@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 + uses: github/codeql-action/autobuild@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 + uses: github/codeql-action/analyze@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 2f3af8b18e..52d29daebe 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # 3.25.8 + uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # 3.25.10 with: sarif_file: results.sarif From 73fc1fd1a383285662be31658c26d578b3489e17 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:00:57 -0400 Subject: [PATCH 032/114] Bump actions/checkout from 4.1.6 to 4.1.7 (#326) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.6 to 4.1.7. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/a5ac7e51b41094c92402da3b24376905380afc29...692973e3d937129bcbf40652eb9f2f61becf3332) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/maven.yml | 2 +- .github/workflows/scorecards-analysis.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e511243b32..8cffd66e8e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 897fe88bb9..30ad32e24a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -29,7 +29,7 @@ jobs: java: [ 8, 11 ] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 602c75aca5..92a3587aca 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Prepare git run: git config --global core.autocrlf false - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: persist-credentials: false - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 52d29daebe..ff25485bde 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -40,7 +40,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: persist-credentials: false From 36c19242c1141c76b4affb9546e1430b9f24c19c Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 18 Jun 2024 09:12:30 -0400 Subject: [PATCH 033/114] Javadoc --- .../java/org/apache/bcel/verifier/structurals/GenericArray.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/verifier/structurals/GenericArray.java b/src/main/java/org/apache/bcel/verifier/structurals/GenericArray.java index 0fa6e412f0..505e1b7ce4 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/GenericArray.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/GenericArray.java @@ -20,7 +20,7 @@ /** * A placeholder class that can be used to create an ObjectType of which has some of the properties arrays have. They - * implement {@link Cloneable} and {@link java.io.Serializable} and they extend {@link Object}. + * implement {@link Cloneable} and {@link Serializable} and they extend {@link Object}. */ public class GenericArray implements Cloneable, Serializable { From 327ff0bb7880559464d97145f21709bbec26054c Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 18 Jun 2024 10:31:34 -0400 Subject: [PATCH 034/114] Bump tests from org.apache.commons:commons-collections4 4.4 to 4.5.0-M2 --- pom.xml | 2 +- src/changes/changes.xml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 84e57a5b71..e6e94cd782 100644 --- a/pom.xml +++ b/pom.xml @@ -479,7 +479,7 @@ org.apache.commons commons-collections4 - 4.4 + 4.5.0-M2 test diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7d2727d953..f426e1ff98 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -63,8 +63,9 @@ The type attribute can be add,update,fix,remove. - Bump org.assertj:assertj-core from 3.25.3 to 3.26.0 #322. - Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.23 to 2.0.0 #309, #318. + Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.0 #322. + Bump tests from org.jetbrains.kotlin:kotlin-stdlib 1.9.23 to 2.0.0 #309, #318. + Bump tests from org.apache.commons:commons-collections4 4.4 to 4.5.0-M2. From 3974fe2a94a23a973cc8ebe3124dc272ee950b35 Mon Sep 17 00:00:00 2001 From: nbauma109 Date: Fri, 21 Jun 2024 23:01:25 +0200 Subject: [PATCH 035/114] Add accessors to model and unit tests, Javadoc (#183) * added accessors to model and unit tests, javadoc comments Co-authored-by: nbauma109 * removed getters that are not useful directly for end users * test for null LocalVariableTypeTable * added test for null class attribute * added test for null LocalVariableTypeTable with Code attribute present * added module flags and tests * @since 6.7.1 -> @since 6.8.0 * Fix unit test ConstantPoolModuleAccessTestCase * Update since tags to 6.10.0 * checkstyles fixes * checkstyle fix on EmptyClass * removed expected jdk.internal.org.jline.terminal.spi.JnaSupport * Fix unit test ConstantPoolModuleAccessTestCase * ConstantPoolModuleAccessTestCase: add url in assert * ConstantPoolModuleAccessTestCase: added message in assertion * ConstantPoolModuleAccessTestCase: remove version number in check * ConstantPoolModuleAccessTestCase: update test for Java 21 * ConstantPoolModuleAccessTestCase: update for Java 21 --------- Co-authored-by: nbauma109 --- .../java/org/apache/bcel/classfile/Code.java | 14 + .../apache/bcel/classfile/FieldOrMethod.java | 16 + .../org/apache/bcel/classfile/JavaClass.java | 16 + .../org/apache/bcel/classfile/Method.java | 15 +- .../org/apache/bcel/classfile/Module.java | 60 ++- .../apache/bcel/classfile/ModuleExports.java | 47 ++- .../apache/bcel/classfile/ModuleOpens.java | 47 ++- .../apache/bcel/classfile/ModuleProvides.java | 43 ++- .../apache/bcel/classfile/ModuleRequires.java | 37 +- .../apache/bcel/AnonymousClassTestCase.java | 14 + .../bcel/LocalVariableTypeTableTestCase.java | 20 + .../ConstantPoolModuleAccessTestCase.java | 358 ++++++++++++++++++ .../java/org/apache/bcel/data/EmptyClass.java | 22 ++ .../generic/FieldAnnotationsTestCase.java | 17 +- .../GeneratingAnnotatedClassesTestCase.java | 4 + 15 files changed, 695 insertions(+), 35 deletions(-) create mode 100644 src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java create mode 100644 src/test/java/org/apache/bcel/data/EmptyClass.java diff --git a/src/main/java/org/apache/bcel/classfile/Code.java b/src/main/java/org/apache/bcel/classfile/Code.java index 8ec211fba4..d94ba66def 100644 --- a/src/main/java/org/apache/bcel/classfile/Code.java +++ b/src/main/java/org/apache/bcel/classfile/Code.java @@ -259,6 +259,20 @@ public LocalVariableTable getLocalVariableTable() { return null; } + /** + * Gets the local variable type table attribute {@link LocalVariableTypeTable}. + * @return LocalVariableTypeTable of Code, if it has one, null otherwise. + * @since 6.10.0 + */ + public LocalVariableTypeTable getLocalVariableTypeTable() { + for (final Attribute attribute : attributes) { + if (attribute instanceof LocalVariableTypeTable) { + return (LocalVariableTypeTable) attribute; + } + } + return null; + } + /** * @return Number of local variables. */ diff --git a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java index 1b2081ed9c..f67c1be725 100644 --- a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java +++ b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java @@ -171,6 +171,22 @@ public final Attribute[] getAttributes() { return attributes; } + /** + * Gets attribute for given tag. + * @return Attribute for given tag, null if not found. + * Refer to {@link org.apache.bcel.Const#ATTR_UNKNOWN} constants named ATTR_* for possible values. + * @since 6.10.0 + */ + @SuppressWarnings("unchecked") + public final T getAttribute(final byte tag) { + for (final Attribute attribute : getAttributes()) { + if (attribute.getTag() == tag) { + return (T) attribute; + } + } + return null; + } + /** * @return Constant pool used by this object. */ diff --git a/src/main/java/org/apache/bcel/classfile/JavaClass.java b/src/main/java/org/apache/bcel/classfile/JavaClass.java index d52336d011..f58999899d 100644 --- a/src/main/java/org/apache/bcel/classfile/JavaClass.java +++ b/src/main/java/org/apache/bcel/classfile/JavaClass.java @@ -489,6 +489,22 @@ public Attribute[] getAttributes() { return attributes; } + /** + * Gets attribute for given tag. + * @return Attribute for given tag, null if not found. + * Refer to {@link org.apache.bcel.Const#ATTR_UNKNOWN} constants named ATTR_* for possible values. + * @since 6.10.0 + */ + @SuppressWarnings("unchecked") + public final T getAttribute(final byte tag) { + for (final Attribute attribute : getAttributes()) { + if (attribute.getTag() == tag) { + return (T) attribute; + } + } + return null; + } + /** * @return class in binary format */ diff --git a/src/main/java/org/apache/bcel/classfile/Method.java b/src/main/java/org/apache/bcel/classfile/Method.java index 57a70ff8e7..8de79040fb 100644 --- a/src/main/java/org/apache/bcel/classfile/Method.java +++ b/src/main/java/org/apache/bcel/classfile/Method.java @@ -177,7 +177,7 @@ public LineNumberTable getLineNumberTable() { } /** - * @return LocalVariableTable of code attribute if any, i.e. the call is forwarded to the Code atribute. + * @return LocalVariableTable of code attribute if any, i.e. the call is forwarded to the Code attribute. */ public LocalVariableTable getLocalVariableTable() { final Code code = getCode(); @@ -187,6 +187,19 @@ public LocalVariableTable getLocalVariableTable() { return code.getLocalVariableTable(); } + /** + * Gets the local variable type table attribute {@link LocalVariableTypeTable}. + * @return LocalVariableTypeTable of code attribute if any, i.e. the call is forwarded to the Code attribute. + * @since 6.10.0 + */ + public LocalVariableTypeTable getLocalVariableTypeTable() { + final Code code = getCode(); + if (code == null) { + return null; + } + return code.getLocalVariableTypeTable(); + } + /** * @return Annotations on the parameters of a method * @since 6.0 diff --git a/src/main/java/org/apache/bcel/classfile/Module.java b/src/main/java/org/apache/bcel/classfile/Module.java index 11aea31697..5915522c16 100644 --- a/src/main/java/org/apache/bcel/classfile/Module.java +++ b/src/main/java/org/apache/bcel/classfile/Module.java @@ -109,7 +109,57 @@ public void accept(final Visitor v) { v.visitModule(this); } - // TODO add more getters and setters? + /** + * Gets version for this module. + * @param cp Array of constants + * @return version from constant pool, "0" if version index is 0 + * @since 6.10.0 + */ + public String getVersion(final ConstantPool cp) { + return moduleVersionIndex == 0 ? "0" : cp.getConstantString(moduleVersionIndex, Const.CONSTANT_Utf8); + } + + /** + * Gets flags for this module. + * @return module flags + * @since 6.10.0 + */ + public int getModuleFlags() { + return moduleFlags; + } + + /** + * Gets module name. + * @param cp Array of constants + * @return module name + * @since 6.10.0 + */ + public String getModuleName(final ConstantPool cp) { + return cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module); + } + + /** + * Gets the array of class names for this module's uses. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @param compactClassName false for original constant pool value, true to replace '/' with '.' + * @return array of used class names + * @since 6.10.0 + */ + public String[] getUsedClassNames(final ConstantPool constantPool, final boolean compactClassName) { + final String[] usedClassNames = new String[usesCount]; + for (int i = 0; i < usesCount; i++) { + usedClassNames[i] = getClassNameAtIndex(constantPool, usesIndex[i], compactClassName); + } + return usedClassNames; + } + + private static String getClassNameAtIndex(final ConstantPool cp, final int index, final boolean compactClassName) { + final String className = cp.getConstantString(index, Const.CONSTANT_Class); + if (compactClassName) { + return Utility.compactClassName(className, false); + } + return className; + } /** * @return deep copy of this attribute @@ -214,9 +264,9 @@ public String toString() { final ConstantPool cp = super.getConstantPool(); final StringBuilder buf = new StringBuilder(); buf.append("Module:\n"); - buf.append(" name: ").append(Utility.pathToPackage(cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module))).append("\n"); + buf.append(" name: ").append(Utility.pathToPackage(getModuleName(cp))).append("\n"); buf.append(" flags: ").append(String.format("%04x", moduleFlags)).append("\n"); - final String version = moduleVersionIndex == 0 ? "0" : cp.getConstantString(moduleVersionIndex, Const.CONSTANT_Utf8); + final String version = getVersion(cp); buf.append(" version: ").append(version).append("\n"); buf.append(" requires(").append(requiresTable.length).append("):\n"); @@ -236,8 +286,8 @@ public String toString() { buf.append(" uses(").append(usesIndex.length).append("):\n"); for (final int index : usesIndex) { - final String className = cp.getConstantString(index, Const.CONSTANT_Class); - buf.append(" ").append(Utility.compactClassName(className, false)).append("\n"); + final String className = getClassNameAtIndex(cp, index, true); + buf.append(" ").append(className).append("\n"); } buf.append(" provides(").append(providesTable.length).append("):\n"); diff --git a/src/main/java/org/apache/bcel/classfile/ModuleExports.java b/src/main/java/org/apache/bcel/classfile/ModuleExports.java index 463ce4fd90..5653e82de8 100644 --- a/src/main/java/org/apache/bcel/classfile/ModuleExports.java +++ b/src/main/java/org/apache/bcel/classfile/ModuleExports.java @@ -53,6 +53,43 @@ public final class ModuleExports implements Cloneable, Node { } } + /** + * Gets the flags for this ModuleExports. + * @return the exportsFlags + * @since 6.10.0 + */ + public int getExportsFlags() { + return exportsFlags; + } + + /** + * Gets an array of module names for this ModuleExports. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @return array of module names following 'exports to' + * @since 6.10.0 + */ + public String[] getToModuleNames(final ConstantPool constantPool) { + final String[] toModuleNames = new String[exportsToCount]; + for (int i = 0; i < exportsToCount; i++) { + toModuleNames[i] = getToModuleNameAtIndex(constantPool, exportsToIndex[i]); + } + return toModuleNames; + } + + private static String getToModuleNameAtIndex(final ConstantPool constantPool, final int index) { + return constantPool.getConstantString(index, Const.CONSTANT_Module); + } + + /** + * Gets the exported package name. + * @param constantPool the constant pool from the ClassFile + * @return the exported package name + * @since 6.10.0 + */ + public String getPackageName(final ConstantPool constantPool) { + return constantPool.constantToString(exportsIndex, Const.CONSTANT_Package); + } + /** * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. @@ -64,8 +101,6 @@ public void accept(final Visitor v) { v.visitModuleExports(this); } - // TODO add more getters and setters? - /** * @return deep copy of this object */ @@ -106,13 +141,13 @@ public String toString() { */ public String toString(final ConstantPool constantPool) { final StringBuilder buf = new StringBuilder(); - final String packageName = constantPool.constantToString(exportsIndex, Const.CONSTANT_Package); - buf.append(Utility.compactClassName(packageName, false)); + final String packageName = getPackageName(constantPool); + buf.append(packageName); buf.append(", ").append(String.format("%04x", exportsFlags)); buf.append(", to(").append(exportsToCount).append("):\n"); for (final int index : exportsToIndex) { - final String moduleName = constantPool.getConstantString(index, Const.CONSTANT_Module); - buf.append(" ").append(Utility.compactClassName(moduleName, false)).append("\n"); + final String moduleName = getToModuleNameAtIndex(constantPool, index); + buf.append(" ").append(moduleName).append("\n"); } return buf.substring(0, buf.length() - 1); // remove the last newline } diff --git a/src/main/java/org/apache/bcel/classfile/ModuleOpens.java b/src/main/java/org/apache/bcel/classfile/ModuleOpens.java index 00c0f3a377..f8da77c7c1 100644 --- a/src/main/java/org/apache/bcel/classfile/ModuleOpens.java +++ b/src/main/java/org/apache/bcel/classfile/ModuleOpens.java @@ -53,6 +53,43 @@ public final class ModuleOpens implements Cloneable, Node { } } + /** + * Gets the flags for this ModuleOpens. + * @return the opensFlags + * @since 6.10.0 + */ + public int getOpensFlags() { + return opensFlags; + } + + /** + * Gets an array of module names for this ModuleOpens. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @return array of module names following 'opens to' + * @since 6.10.0 + */ + public String[] getToModuleNames(final ConstantPool constantPool) { + final String[] toModuleNames = new String[opensToCount]; + for (int i = 0; i < opensToCount; i++) { + toModuleNames[i] = getToModuleNameAtIndex(constantPool, opensToIndex[i]); + } + return toModuleNames; + } + + private static String getToModuleNameAtIndex(final ConstantPool constantPool, final int index) { + return constantPool.getConstantString(index, Const.CONSTANT_Module); + } + + /** + * Gets the opened package name. + * @param constantPool the constant pool from the ClassFile + * @return the opened package name + * @since 6.10.0 + */ + public String getPackageName(final ConstantPool constantPool) { + return constantPool.constantToString(opensIndex, Const.CONSTANT_Package); + } + /** * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. @@ -64,8 +101,6 @@ public void accept(final Visitor v) { v.visitModuleOpens(this); } - // TODO add more getters and setters? - /** * @return deep copy of this object */ @@ -106,13 +141,13 @@ public String toString() { */ public String toString(final ConstantPool constantPool) { final StringBuilder buf = new StringBuilder(); - final String packageName = constantPool.constantToString(opensIndex, Const.CONSTANT_Package); - buf.append(Utility.compactClassName(packageName, false)); + final String packageName = getPackageName(constantPool); + buf.append(packageName); buf.append(", ").append(String.format("%04x", opensFlags)); buf.append(", to(").append(opensToCount).append("):\n"); for (final int index : opensToIndex) { - final String moduleName = constantPool.getConstantString(index, Const.CONSTANT_Module); - buf.append(" ").append(Utility.compactClassName(moduleName, false)).append("\n"); + final String moduleName = getToModuleNameAtIndex(constantPool, index); + buf.append(" ").append(moduleName).append("\n"); } return buf.substring(0, buf.length() - 1); // remove the last newline } diff --git a/src/main/java/org/apache/bcel/classfile/ModuleProvides.java b/src/main/java/org/apache/bcel/classfile/ModuleProvides.java index af0778afb7..8c88f1709a 100644 --- a/src/main/java/org/apache/bcel/classfile/ModuleProvides.java +++ b/src/main/java/org/apache/bcel/classfile/ModuleProvides.java @@ -51,6 +51,39 @@ public final class ModuleProvides implements Cloneable, Node { } } + /** + * Gets the array of implementation class names for this ModuleProvides. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @param compactClassName false for original constant pool value, true to replace '/' with '.' + * @return array of implementation class names + * @since 6.10.0 + */ + public String[] getImplementationClassNames(final ConstantPool constantPool, final boolean compactClassName) { + final String[] implementationClassNames = new String[providesWithCount]; + for (int i = 0; i < providesWithCount; i++) { + implementationClassNames[i] = getImplementationClassNameAtIndex(constantPool, providesWithIndex[i], compactClassName); + } + return implementationClassNames; + } + + private static String getImplementationClassNameAtIndex(final ConstantPool constantPool, final int index, final boolean compactClassName) { + final String className = constantPool.getConstantString(index, Const.CONSTANT_Class); + if (compactClassName) { + return Utility.compactClassName(className, false); + } + return className; + } + + /** + * Gets the interface name for this ModuleProvides. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @return interface name + * @since 6.10.0 + */ + public String getInterfaceName(final ConstantPool constantPool) { + return constantPool.constantToString(providesIndex, Const.CONSTANT_Class); + } + /** * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. @@ -62,8 +95,6 @@ public void accept(final Visitor v) { v.visitModuleProvides(this); } - // TODO add more getters and setters? - /** * @return deep copy of this object */ @@ -103,12 +134,12 @@ public String toString() { */ public String toString(final ConstantPool constantPool) { final StringBuilder buf = new StringBuilder(); - final String interfaceName = constantPool.constantToString(providesIndex, Const.CONSTANT_Class); - buf.append(Utility.compactClassName(interfaceName, false)); + final String interfaceName = getInterfaceName(constantPool); + buf.append(interfaceName); buf.append(", with(").append(providesWithCount).append("):\n"); for (final int index : providesWithIndex) { - final String className = constantPool.getConstantString(index, Const.CONSTANT_Class); - buf.append(" ").append(Utility.compactClassName(className, false)).append("\n"); + final String className = getImplementationClassNameAtIndex(constantPool, index, true); + buf.append(" ").append(className).append("\n"); } return buf.substring(0, buf.length() - 1); // remove the last newline } diff --git a/src/main/java/org/apache/bcel/classfile/ModuleRequires.java b/src/main/java/org/apache/bcel/classfile/ModuleRequires.java index 371c35c6e7..678b0843cd 100644 --- a/src/main/java/org/apache/bcel/classfile/ModuleRequires.java +++ b/src/main/java/org/apache/bcel/classfile/ModuleRequires.java @@ -48,6 +48,35 @@ public final class ModuleRequires implements Cloneable, Node { requiresVersionIndex = file.readUnsignedShort(); } + /** + * Gets the flags for this ModuleRequires. + * @return the requiresFlags + * @since 6.10.0 + */ + public int getRequiresFlags() { + return requiresFlags; + } + + /** + * Gets the required version from the constant pool. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @return required version, "0" if version index is 0. + * @since 6.10.0 + */ + public String getVersion(final ConstantPool constantPool) { + return requiresVersionIndex == 0 ? "0" : constantPool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8); + } + + /** + * Gets the module name from the constant pool. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @return module name + * @since 6.10.0 + */ + public String getModuleName(final ConstantPool constantPool) { + return constantPool.constantToString(requiresIndex, Const.CONSTANT_Module); + } + /** * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. @@ -59,8 +88,6 @@ public void accept(final Visitor v) { v.visitModuleRequires(this); } - // TODO add more getters and setters? - /** * @return deep copy of this object */ @@ -98,10 +125,10 @@ public String toString() { */ public String toString(final ConstantPool constantPool) { final StringBuilder buf = new StringBuilder(); - final String moduleName = constantPool.constantToString(requiresIndex, Const.CONSTANT_Module); - buf.append(Utility.compactClassName(moduleName, false)); + final String moduleName = getModuleName(constantPool); + buf.append(moduleName); buf.append(", ").append(String.format("%04x", requiresFlags)); - final String version = requiresVersionIndex == 0 ? "0" : constantPool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8); + final String version = getVersion(constantPool); buf.append(", ").append(version); return buf.toString(); } diff --git a/src/test/java/org/apache/bcel/AnonymousClassTestCase.java b/src/test/java/org/apache/bcel/AnonymousClassTestCase.java index 1d65fa965b..ed6f0dd7f4 100644 --- a/src/test/java/org/apache/bcel/AnonymousClassTestCase.java +++ b/src/test/java/org/apache/bcel/AnonymousClassTestCase.java @@ -17,10 +17,15 @@ package org.apache.bcel; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import org.apache.bcel.classfile.InnerClass; +import org.apache.bcel.classfile.InnerClasses; import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.data.EmptyClass; import org.junit.jupiter.api.Test; public class AnonymousClassTestCase extends AbstractTestCase { @@ -45,6 +50,15 @@ public void testRegularClassIsNotAnonymous() throws ClassNotFoundException { assertFalse(clazz.isNested(), "regular outer classes are not nested"); } + @Test + public void testRegularClassInnerClasses() throws ClassNotFoundException { + final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.AnonymousClassTest"); + final InnerClasses innerClasses = clazz.getAttribute(Const.ATTR_INNER_CLASSES); + final InnerClass[] innerClassArray = innerClasses.getInnerClasses(); + assertEquals(3, innerClassArray.length); + assertNull(Repository.lookupClass(EmptyClass.class).getAttribute(Const.ATTR_INNER_CLASSES)); + } + @Test public void testStaticInnerClassIsNotAnonymous() throws ClassNotFoundException { final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.AnonymousClassTest$Y"); diff --git a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java index 6d5068efc1..6855069e3e 100644 --- a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java +++ b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.LocalVariableTypeTable; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.ACONST_NULL; import org.apache.bcel.generic.ALOAD; @@ -34,6 +35,9 @@ import org.apache.bcel.generic.Type; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + public class LocalVariableTypeTableTestCase extends AbstractTestCase { public class TestClassLoader extends ClassLoader { @@ -143,4 +147,20 @@ public void testWithGenericArguement() throws ClassNotFoundException, NoSuchMeth method = cls.getDeclaredMethod("d", List.class, String.class); method.invoke(null, new LinkedList<>(), "d2"); } + + @Test + public void testGetLocalVariableTypeTable() throws ClassNotFoundException, NoSuchMethodException, SecurityException { + final JavaClass testJavaClass = getTestJavaClass("org/apache/commons/lang3/function/TriFunction"); + final String expectedToString = "LocalVariableTypes(startPc = 0, length = 17, index = 0:org.apache.commons.lang3.function.TriFunction this)"; + for (final Method method : testJavaClass.getMethods()) { + if ("lambda$andThen$0".equals(method.getName())) { + final LocalVariableTypeTable localVariableTypeTable = method.getLocalVariableTypeTable(); + assertEquals(expectedToString, localVariableTypeTable.toString()); + } + if ("apply".equals(method.getName())) { + assertNull(method.getLocalVariableTypeTable()); + } + } + assertNull(Repository.lookupClass(Object.class).getMethod(Object.class.getMethod("toString")).getLocalVariableTypeTable()); + } } diff --git a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java new file mode 100644 index 0000000000..5202c4be1c --- /dev/null +++ b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java @@ -0,0 +1,358 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.bcel.classfile; + +import org.apache.bcel.Const; +import org.junit.jupiter.api.Test; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests {@code module-info.class} files. + */ +public class ConstantPoolModuleAccessTestCase { + + @Test + public void testJREModules() throws Exception { + final Enumeration moduleURLs = getClass().getClassLoader().getResources("module-info.class"); + while (moduleURLs.hasMoreElements()) { + final URL url = moduleURLs.nextElement(); + try (InputStream inputStream = url.openStream()) { + final ClassParser classParser = new ClassParser(inputStream, "module-info.class"); + final JavaClass javaClass = classParser.parse(); + final ConstantPool constantPool = javaClass.getConstantPool(); + final EmptyVisitor visitor = new EmptyVisitor() { + @Override + public void visitModule(final Module obj) { + if (url.getPath().contains("/commons-")) { + assertEquals(4096, obj.getModuleFlags(), url.toString()); + } else { + assertEquals(0, obj.getModuleFlags(), url.toString()); + } + final String[] usedClassNames = obj.getUsedClassNames(constantPool, true); + if (url.getPath().contains("junit-jupiter-engine")) { + assertEquals(1, usedClassNames.length); + assertEquals("org.junit.jupiter.api.extension.Extension", usedClassNames[0]); + } else if (url.getPath().contains("junit-platform-launcher")) { + final List expected = new ArrayList<>(); + expected.add("org.junit.platform.engine.TestEngine"); + expected.add("org.junit.platform.launcher.LauncherDiscoveryListener"); + expected.add("org.junit.platform.launcher.LauncherInterceptor"); + expected.add("org.junit.platform.launcher.LauncherSessionListener"); + expected.add("org.junit.platform.launcher.PostDiscoveryFilter"); + expected.add("org.junit.platform.launcher.TestExecutionListener"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.rmi/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("java.rmi.server.RMIClassLoaderSpi"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.xml/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.xml.datatype.DatatypeFactory"); + expected.add("javax.xml.parsers.DocumentBuilderFactory"); + expected.add("javax.xml.parsers.SAXParserFactory"); + expected.add("javax.xml.stream.XMLEventFactory"); + expected.add("javax.xml.stream.XMLInputFactory"); + expected.add("javax.xml.stream.XMLOutputFactory"); + expected.add("javax.xml.transform.TransformerFactory"); + expected.add("javax.xml.validation.SchemaFactory"); + expected.add("javax.xml.xpath.XPathFactory"); + expected.add("org.xml.sax.XMLReader"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.datatransfer/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("sun.datatransfer.DesktopDatatransferService"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.desktop/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("java.awt.im.spi.InputMethodDescriptor"); + expected.add("javax.accessibility.AccessibilityProvider"); + expected.add("javax.imageio.spi.ImageInputStreamSpi"); + expected.add("javax.imageio.spi.ImageOutputStreamSpi"); + expected.add("javax.imageio.spi.ImageReaderSpi"); + expected.add("javax.imageio.spi.ImageTranscoderSpi"); + expected.add("javax.imageio.spi.ImageWriterSpi"); + expected.add("javax.print.PrintServiceLookup"); + expected.add("javax.print.StreamPrintServiceFactory"); + expected.add("javax.sound.midi.spi.MidiDeviceProvider"); + expected.add("javax.sound.midi.spi.MidiFileReader"); + expected.add("javax.sound.midi.spi.MidiFileWriter"); + expected.add("javax.sound.midi.spi.SoundbankReader"); + expected.add("javax.sound.sampled.spi.AudioFileReader"); + expected.add("javax.sound.sampled.spi.AudioFileWriter"); + expected.add("javax.sound.sampled.spi.FormatConversionProvider"); + expected.add("javax.sound.sampled.spi.MixerProvider"); + expected.add("sun.swing.InteropProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.naming/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.naming.ldap.StartTlsResponse"); + expected.add("javax.naming.spi.InitialContextFactory"); + if (javaClass.getMajor() > Const.MAJOR_11) { + expected.add("javax.naming.ldap.spi.LdapDnsProvider"); + } + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.prefs/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("java.util.prefs.PreferencesFactory"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.base/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("java.lang.System$LoggerFinder"); + expected.add("java.net.ContentHandlerFactory"); + if (javaClass.getMajor() > Const.MAJOR_17) { + expected.add("java.net.spi.InetAddressResolverProvider"); + } + expected.add("java.net.spi.URLStreamHandlerProvider"); + expected.add("java.nio.channels.spi.AsynchronousChannelProvider"); + expected.add("java.nio.channels.spi.SelectorProvider"); + expected.add("java.nio.charset.spi.CharsetProvider"); + expected.add("java.nio.file.spi.FileSystemProvider"); + expected.add("java.nio.file.spi.FileTypeDetector"); + expected.add("java.security.Provider"); + expected.add("java.text.spi.BreakIteratorProvider"); + expected.add("java.text.spi.CollatorProvider"); + expected.add("java.text.spi.DateFormatProvider"); + expected.add("java.text.spi.DateFormatSymbolsProvider"); + expected.add("java.text.spi.DecimalFormatSymbolsProvider"); + expected.add("java.text.spi.NumberFormatProvider"); + expected.add("java.time.chrono.AbstractChronology"); + expected.add("java.time.chrono.Chronology"); + expected.add("java.time.zone.ZoneRulesProvider"); + if (javaClass.getMajor() > Const.MAJOR_11) { + expected.add("java.util.random.RandomGenerator"); + } + expected.add("java.util.spi.CalendarDataProvider"); + expected.add("java.util.spi.CalendarNameProvider"); + expected.add("java.util.spi.CurrencyNameProvider"); + expected.add("java.util.spi.LocaleNameProvider"); + expected.add("java.util.spi.ResourceBundleControlProvider"); + expected.add("java.util.spi.ResourceBundleProvider"); + expected.add("java.util.spi.TimeZoneNameProvider"); + expected.add("java.util.spi.ToolProvider"); + expected.add("javax.security.auth.spi.LoginModule"); + if (javaClass.getMajor() > Const.MAJOR_17) { + expected.add("jdk.internal.io.JdkConsoleProvider"); + } + expected.add("jdk.internal.logger.DefaultLoggerFinder"); + expected.add("sun.text.spi.JavaTimeDateTimePatternProvider"); + expected.add("sun.util.locale.provider.LocaleDataMetaInfo"); + expected.add("sun.util.resources.LocaleData$CommonResourceBundleProvider"); + expected.add("sun.util.resources.LocaleData$SupplementaryResourceBundleProvider"); + expected.add("sun.util.spi.CalendarProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.management.agent/module-info.class") && javaClass.getMajor() < Const.MAJOR_21) { + final List expected = new ArrayList<>(); + expected.add("jdk.internal.agent.spi.AgentProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.management/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.management.remote.JMXConnectorProvider"); + expected.add("javax.management.remote.JMXConnectorServerProvider"); + expected.add("sun.management.spi.PlatformMBeanProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.sql/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("java.sql.Driver"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.httpserver/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("com.sun.net.httpserver.spi.HttpServerProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.sql.rowset/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.sql.rowset.RowSetFactory"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.compiler/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.tools.DocumentationTool"); + expected.add("javax.tools.JavaCompiler"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.scripting/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.script.ScriptEngineFactory"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.dynalink/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("jdk.dynalink.linker.GuardingDynamicLinkerExporter"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jdi/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("com.sun.jdi.connect.Connector"); + expected.add("com.sun.jdi.connect.spi.TransportService"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.compiler/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.annotation.processing.Processor"); + expected.add("com.sun.source.util.Plugin"); + if (javaClass.getMajor() > Const.MAJOR_11) { + expected.add("com.sun.tools.doclint.DocLint"); + } + expected.add("com.sun.tools.javac.platform.PlatformProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jconsole/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("com.sun.tools.jconsole.JConsolePlugin"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.attach/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("com.sun.tools.attach.spi.AttachProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jshell/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("jdk.jshell.spi.ExecutionControlProvider"); + expected.add("jdk.internal.editor.spi.BuildInEditorProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.internal.le/module-info.class")) { + final List expected = new ArrayList<>(); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jlink/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("jdk.tools.jlink.plugin.Plugin"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.internal.jvmstat/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("sun.jvmstat.monitor.MonitoredHostService"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jpackage/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("jdk.jpackage.internal.Bundler"); + expected.add("jdk.jpackage.internal.Bundlers"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.naming.ldap/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("com.sun.jndi.ldap.spi.LdapDnsProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jsobject/module-info.class") && javaClass.getMajor() == Const.MAJOR_11) { + final List expected = new ArrayList<>(); + expected.add("jdk.internal.netscape.javascript.spi.JSObjectProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/org/assertj/assertj-core/")) { + final List expected = new ArrayList<>(); + expected.add("org.assertj.core.configuration.Configuration"); + expected.add("org.assertj.core.presentation.Representation"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else { + assertEquals(0, usedClassNames.length, "Found " + Arrays.toString(usedClassNames) + " in " + url.getPath()); + } + super.visitModule(obj); + } + + @Override + public void visitModuleExports(final ModuleExports obj) { + assertEquals(0, obj.getExportsFlags(), url.toString()); + final String packageName = obj.getPackageName(constantPool); + final String[] toModuleNames = obj.getToModuleNames(constantPool); + if (url.getPath().contains("junit-platform-commons")) { + final List expected = new ArrayList<>(); + expected.add("org.junit.jupiter.api"); + expected.add("org.junit.jupiter.engine"); + expected.add("org.junit.jupiter.migrationsupport"); + expected.add("org.junit.jupiter.params"); + expected.add("org.junit.platform.console"); + expected.add("org.junit.platform.engine"); + expected.add("org.junit.platform.launcher"); + expected.add("org.junit.platform.reporting"); + expected.add("org.junit.platform.runner"); + expected.add("org.junit.platform.suite.api"); + switch (packageName) { + case "org.junit.platform.commons.util": + expected.add("org.junit.platform.suite.commons"); + expected.add("org.junit.platform.suite.engine"); + expected.add("org.junit.platform.testkit"); + expected.add("org.junit.vintage.engine"); + assertEquals(expected, Arrays.asList(toModuleNames)); + break; + case "org.junit.platform.commons.logging": + expected.add("org.junit.platform.suite.engine"); + expected.add("org.junit.platform.testkit"); + expected.add("org.junit.vintage.engine"); + assertEquals(expected, Arrays.asList(toModuleNames)); + break; + default: + assertEquals(0, toModuleNames.length); + break; + } + } + super.visitModuleExports(obj); + } + + @Override + public void visitModuleProvides(final ModuleProvides obj) { + final String interfaceName = obj.getInterfaceName(constantPool); + final String[] implementationClassNames = obj.getImplementationClassNames(constantPool, true); + if (url.getPath().contains("junit-jupiter-engine")) { + assertEquals("org.junit.platform.engine.TestEngine", interfaceName); + assertEquals(1, implementationClassNames.length); + assertEquals("org.junit.jupiter.engine.JupiterTestEngine", implementationClassNames[0]); + } else if (url.getPath().contains("junit-platform-launcher")) { + assertEquals("org.junit.platform.launcher.TestExecutionListener", interfaceName); + assertEquals(1, implementationClassNames.length); + assertEquals("org.junit.platform.launcher.listeners.UniqueIdTrackingListener", implementationClassNames[0]); + } + super.visitModuleProvides(obj); + } + + @Override + public void visitModuleOpens(final ModuleOpens obj) { + assertEquals(0, obj.getOpensFlags(), url.toString()); + final String packageName = obj.getPackageName(constantPool); + final String[] toModuleNames = obj.getToModuleNames(constantPool); + if (url.getPath().contains("junit-jupiter-engine")) { + assertEquals("org.junit.jupiter.engine.extension", packageName); + assertEquals(1, toModuleNames.length); + assertEquals("org.junit.platform.commons", toModuleNames[0]); + } + if (url.getPath().contains("junit-jupiter-api")) { + assertEquals("org.junit.jupiter.api.condition", packageName); + assertEquals(1, toModuleNames.length); + assertEquals("org.junit.platform.commons", toModuleNames[0]); + } + super.visitModuleOpens(obj); + } + + @Override + public void visitModuleRequires(final ModuleRequires obj) { + if (url.getPath().contains("junit-jupiter-engine")) { + final String moduleName = obj.getModuleName(constantPool); + final Map expected = new HashMap<>(); + expected.put("java.base", 32768); + expected.put("org.apiguardian.api", 64); + expected.put("org.junit.jupiter.api", 0); + expected.put("org.junit.platform.commons", 0); + expected.put("org.junit.platform.engine", 0); + expected.put("org.opentest4j", 0); + assertTrue(expected.containsKey(moduleName)); + assertEquals(expected.get(moduleName), obj.getRequiresFlags(), moduleName); + } + super.visitModuleRequires(obj); + } + }; + javaClass.accept(new DescendingVisitor(javaClass, visitor)); + } + } + } +} diff --git a/src/test/java/org/apache/bcel/data/EmptyClass.java b/src/test/java/org/apache/bcel/data/EmptyClass.java new file mode 100644 index 0000000000..b10c1d03d6 --- /dev/null +++ b/src/test/java/org/apache/bcel/data/EmptyClass.java @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel.data; + +public class EmptyClass { +} + diff --git a/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java b/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java index 31d66f3bd2..5ba8db0f7f 100644 --- a/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java +++ b/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java @@ -17,13 +17,8 @@ package org.apache.bcel.generic; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.io.File; -import java.io.IOException; - import org.apache.bcel.AbstractTestCase; +import org.apache.bcel.Const; import org.apache.bcel.classfile.AnnotationEntry; import org.apache.bcel.classfile.ElementValuePair; import org.apache.bcel.classfile.Field; @@ -31,6 +26,14 @@ import org.apache.bcel.util.SyntheticRepository; import org.junit.jupiter.api.Test; +import java.io.File; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class FieldAnnotationsTestCase extends AbstractTestCase { // helper methods public void checkAnnotatedField(final JavaClass clazz, final String fieldname, final String AnnotationEntryName, final String AnnotationEntryElementName, @@ -40,6 +43,8 @@ public void checkAnnotatedField(final JavaClass clazz, final String fieldname, f final AnnotationEntry[] fieldAnnotationEntrys = f.getAnnotationEntries(); if (f.getName().equals(fieldname)) { checkAnnotationEntry(fieldAnnotationEntrys[0], AnnotationEntryName, AnnotationEntryElementName, AnnotationEntryElementValue); + assertNotNull(f.getAttribute(Const.ATTR_RUNTIME_VISIBLE_ANNOTATIONS)); + assertNull(f.getAttribute(Const.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS)); } } } diff --git a/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java b/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java index 056453c1b0..c2924d3408 100644 --- a/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java +++ b/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java @@ -17,6 +17,8 @@ package org.apache.bcel.generic; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -89,6 +91,8 @@ private void assertParameterAnnotations(final Method method, final int... expect assertSimpleElementValue(annos[0]); } } + assertNotNull(method.getAttribute(Const.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS)); + assertNull(method.getAttribute(Const.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS)); } private void assertSimpleElementValue(final AnnotationEntry anno) { From 3e5642d58114002822fff938d686ac977bae4214 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 21 Jun 2024 17:03:22 -0400 Subject: [PATCH 036/114] Add accessors to model and unit tests, Javadoc #183 --- src/changes/changes.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f426e1ff98..891208fe89 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -61,7 +61,8 @@ The type attribute can be add,update,fix,remove. - + + Add accessors to model and unit tests, Javadoc #183. Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.0 #322. Bump tests from org.jetbrains.kotlin:kotlin-stdlib 1.9.23 to 2.0.0 #309, #318. From 0e712d049690603cdc432594ea6610cbf667e7ab Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Fri, 21 Jun 2024 17:06:15 -0400 Subject: [PATCH 037/114] Next version will be 6.10.0 --- pom.xml | 8 ++++---- src/changes/changes.xml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index e6e94cd782..95c352793c 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ org.apache.bcel bcel jar - 6.9.1-SNAPSHOT + 6.10.0-SNAPSHOT Apache Commons BCEL Apache Commons Bytecode Engineering Library @@ -48,11 +48,11 @@ 1.8 bcel org.apache.bcel - 6.9.0 - 6.9.1 + 6.10.0 + 6.10.1 true RC1 - 6.8.2 + 6.9.0 (Java 8 or above) https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-bcel scm:svn:https://dist.apache.org/repos/dist/dev/commons/${commons.componentid} diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f426e1ff98..3d4d9a4cb2 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -59,7 +59,7 @@ The type attribute can be add,update,fix,remove. Defining changes.version allows one to create the RN without first removing the SNAPSHOT suffix. --> - + From 87c9eaec1a9d82f0c93719f8b22d35c542ed1e99 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:43 -0400 Subject: [PATCH 038/114] Fix PMD UnnecessaryFullyQualifiedName --- src/main/java/org/apache/bcel/classfile/ArrayElementValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/classfile/ArrayElementValue.java b/src/main/java/org/apache/bcel/classfile/ArrayElementValue.java index d932b112e2..e7c7e1d302 100644 --- a/src/main/java/org/apache/bcel/classfile/ArrayElementValue.java +++ b/src/main/java/org/apache/bcel/classfile/ArrayElementValue.java @@ -31,7 +31,7 @@ public ArrayElementValue(final int type, final ElementValue[] elementValues, fin if (type != ARRAY) { throw new ClassFormatException("Only element values of type array can be built with this ctor - type specified: " + type); } - this.elementValues = elementValues != null ? elementValues : ElementValue.EMPTY_ARRAY; + this.elementValues = elementValues != null ? elementValues : EMPTY_ARRAY; } @Override From 3c8136228ad4c431ac1f65c4cdf6854493134d21 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:44 -0400 Subject: [PATCH 039/114] Fix PMD UnnecessaryFullyQualifiedName --- src/main/java/org/apache/bcel/classfile/Code.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/classfile/Code.java b/src/main/java/org/apache/bcel/classfile/Code.java index d94ba66def..e20b70d1e7 100644 --- a/src/main/java/org/apache/bcel/classfile/Code.java +++ b/src/main/java/org/apache/bcel/classfile/Code.java @@ -103,7 +103,7 @@ public Code(final Code code) { final int attributesCount = file.readUnsignedShort(); attributes = new Attribute[attributesCount]; for (int i = 0; i < attributesCount; i++) { - attributes[i] = Attribute.readAttribute(file, constantPool); + attributes[i] = readAttribute(file, constantPool); } /* * Adjust length, because of setAttributes in this(), s.b. length is incorrect, because it didn't take the internal From f50364fe6322fe9bed29570ba56b0d93fd69f327 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:44 -0400 Subject: [PATCH 040/114] Fix PMD UnnecessaryFullyQualifiedName --- src/main/java/org/apache/bcel/classfile/ConstantUtf8.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java b/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java index 7ac35fb5a7..01cc7d42c8 100644 --- a/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java +++ b/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java @@ -77,7 +77,7 @@ protected boolean removeEldestEntry(final Map.Entry eldest private static final int MAX_ENTRY_SIZE = Integer.getInteger(SYS_PROP_CACHE_MAX_ENTRY_SIZE, 200).intValue(); static boolean isEnabled() { - return Cache.MAX_ENTRIES > 0 && MAX_ENTRY_SIZE > 0; + return MAX_ENTRIES > 0 && MAX_ENTRY_SIZE > 0; } } From e9d274cbf6968cc26d613d7f8f3b47249fcd650c Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:45 -0400 Subject: [PATCH 041/114] Fix PMD UnnecessaryFullyQualifiedName --- src/main/java/org/apache/bcel/classfile/ElementValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/classfile/ElementValue.java b/src/main/java/org/apache/bcel/classfile/ElementValue.java index 5619f48623..2ad5b14e03 100644 --- a/src/main/java/org/apache/bcel/classfile/ElementValue.java +++ b/src/main/java/org/apache/bcel/classfile/ElementValue.java @@ -121,7 +121,7 @@ public static ElementValue readElementValue(final DataInput input, final Constan final int numArrayVals = input.readUnsignedShort(); final ElementValue[] evalues = new ElementValue[numArrayVals]; for (int j = 0; j < numArrayVals; j++) { - evalues[j] = ElementValue.readElementValue(input, cpool, arrayNesting); + evalues[j] = readElementValue(input, cpool, arrayNesting); } return new ArrayElementValue(ARRAY, evalues, cpool); From dfe6ea7fe3597594c0fa1d3947bdd77e72c75bbe Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:46 -0400 Subject: [PATCH 042/114] Fix PMD UnnecessaryFullyQualifiedName --- src/main/java/org/apache/bcel/classfile/JavaClass.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/bcel/classfile/JavaClass.java b/src/main/java/org/apache/bcel/classfile/JavaClass.java index f58999899d..fa49fbc398 100644 --- a/src/main/java/org/apache/bcel/classfile/JavaClass.java +++ b/src/main/java/org/apache/bcel/classfile/JavaClass.java @@ -467,7 +467,7 @@ public JavaClass[] getAllInterfaces() throws ClassNotFoundException { queue.enqueue(iface); } } - return allInterfaces.toArray(JavaClass.EMPTY_ARRAY); + return allInterfaces.toArray(EMPTY_ARRAY); } /** @@ -681,7 +681,7 @@ public JavaClass[] getSuperClasses() throws ClassNotFoundException { for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) { allSuperClasses.add(clazz); } - return allSuperClasses.toArray(JavaClass.EMPTY_ARRAY); + return allSuperClasses.toArray(EMPTY_ARRAY); } /** From b81876d6df48250b59873d5380768b74b22a5ea4 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:46 -0400 Subject: [PATCH 043/114] Fix PMD UnnecessaryFullyQualifiedName --- .../org/apache/bcel/classfile/Utility.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/apache/bcel/classfile/Utility.java b/src/main/java/org/apache/bcel/classfile/Utility.java index 76fc8932ab..2e54d2a374 100644 --- a/src/main/java/org/apache/bcel/classfile/Utility.java +++ b/src/main/java/org/apache/bcel/classfile/Utility.java @@ -1466,8 +1466,8 @@ public static String typeSignatureToString(final String signature, final boolean } else { type.append(typeSignatureToString(signature.substring(consumedChars), chopit)); // update our consumed count by the number of characters the for type argument - consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars; - wrap(Utility.CONSUMER_CHARS, consumedChars); + consumedChars = unwrap(CONSUMER_CHARS) + consumedChars; + wrap(CONSUMER_CHARS, consumedChars); } // are there more TypeArguments? @@ -1487,8 +1487,8 @@ public static String typeSignatureToString(final String signature, final boolean } else { type.append(typeSignatureToString(signature.substring(consumedChars), chopit)); // update our consumed count by the number of characters the for type argument - consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars; - wrap(Utility.CONSUMER_CHARS, consumedChars); + consumedChars = unwrap(CONSUMER_CHARS) + consumedChars; + wrap(CONSUMER_CHARS, consumedChars); } } @@ -1505,14 +1505,14 @@ public static String typeSignatureToString(final String signature, final boolean // update our consumed count by the number of characters the for type argument // note that this count includes the "L" we added, but that is ok // as it accounts for the "." we didn't consume - consumedChars = unwrap(Utility.CONSUMER_CHARS) + consumedChars; - wrap(Utility.CONSUMER_CHARS, consumedChars); + consumedChars = unwrap(CONSUMER_CHARS) + consumedChars; + wrap(CONSUMER_CHARS, consumedChars); return type.toString(); } if (signature.charAt(consumedChars) != ';') { throw new ClassFormatException("Invalid signature: " + signature); } - wrap(Utility.CONSUMER_CHARS, consumedChars + 1); // remove final ";" + wrap(CONSUMER_CHARS, consumedChars + 1); // remove final ";" return type.toString(); } case 'S': @@ -1533,9 +1533,9 @@ public static String typeSignatureToString(final String signature, final boolean // The rest of the string denotes a '' type = typeSignatureToString(signature.substring(n), chopit); // corrected concurrent private static field acess - // Utility.consumed_chars += consumed_chars; is replaced by: - final int temp = unwrap(Utility.CONSUMER_CHARS) + consumedChars; - wrap(Utility.CONSUMER_CHARS, temp); + // consumed_chars += consumed_chars; is replaced by: + final int temp = unwrap(CONSUMER_CHARS) + consumedChars; + wrap(CONSUMER_CHARS, temp); return type + brackets.toString(); } case 'V': From c8a83a85d6b0be76964bc6cfce11762cb55cbd34 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:47 -0400 Subject: [PATCH 044/114] Fix PMD UnnecessaryFullyQualifiedName --- .../java/org/apache/bcel/generic/ArrayElementValueGen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/bcel/generic/ArrayElementValueGen.java b/src/main/java/org/apache/bcel/generic/ArrayElementValueGen.java index 21442263d5..97a15b6896 100644 --- a/src/main/java/org/apache/bcel/generic/ArrayElementValueGen.java +++ b/src/main/java/org/apache/bcel/generic/ArrayElementValueGen.java @@ -43,7 +43,7 @@ public ArrayElementValueGen(final ArrayElementValue value, final ConstantPoolGen evalues = new ArrayList<>(); final ElementValue[] in = value.getElementValuesArray(); for (final ElementValue element : in) { - evalues.add(ElementValueGen.copy(element, cpool, copyPoolEntries)); + evalues.add(copy(element, cpool, copyPoolEntries)); } } @@ -57,7 +57,7 @@ public ArrayElementValueGen(final int type, final ElementValue[] elementValues, if (type != ARRAY) { throw new IllegalArgumentException("Only element values of type array can be built with this ctor - type specified: " + type); } - this.evalues = Streams.of(elementValues).map(e -> ElementValueGen.copy(e, cpool, true)).collect(Collectors.toList()); + this.evalues = Streams.of(elementValues).map(e -> copy(e, cpool, true)).collect(Collectors.toList()); } public void addElement(final ElementValueGen gen) { From 4f719bd13afd3b91e7cc7074fb7210d495af5a1d Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:47 -0400 Subject: [PATCH 045/114] Fix PMD UnnecessaryFullyQualifiedName --- .../java/org/apache/bcel/generic/ClassElementValueGen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/bcel/generic/ClassElementValueGen.java b/src/main/java/org/apache/bcel/generic/ClassElementValueGen.java index e02366ffd1..2a95d40a44 100644 --- a/src/main/java/org/apache/bcel/generic/ClassElementValueGen.java +++ b/src/main/java/org/apache/bcel/generic/ClassElementValueGen.java @@ -43,12 +43,12 @@ public ClassElementValueGen(final ClassElementValue value, final ConstantPoolGen } protected ClassElementValueGen(final int typeIdx, final ConstantPoolGen cpool) { - super(ElementValueGen.CLASS, cpool); + super(CLASS, cpool); this.idx = typeIdx; } public ClassElementValueGen(final ObjectType t, final ConstantPoolGen cpool) { - super(ElementValueGen.CLASS, cpool); + super(CLASS, cpool); // this.idx = cpool.addClass(t); idx = cpool.addUtf8(t.getSignature()); } From 4204ab420f17b560b0710b187b9521b2ad869f62 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:48 -0400 Subject: [PATCH 046/114] Fix PMD UnnecessaryFullyQualifiedName --- .../java/org/apache/bcel/generic/EnumElementValueGen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java b/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java index 954a739aba..89fee99b01 100644 --- a/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java +++ b/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java @@ -48,7 +48,7 @@ public EnumElementValueGen(final EnumElementValue value, final ConstantPoolGen c * This ctor is used for deserialization */ protected EnumElementValueGen(final int typeIdx, final int valueIdx, final ConstantPoolGen cpool) { - super(ElementValueGen.ENUM_CONSTANT, cpool); + super(ENUM_CONSTANT, cpool); if (super.getElementValueType() != ENUM_CONSTANT) { throw new IllegalArgumentException("Only element values of type enum can be built with this ctor - type specified: " + super.getElementValueType()); } @@ -57,7 +57,7 @@ protected EnumElementValueGen(final int typeIdx, final int valueIdx, final Const } public EnumElementValueGen(final ObjectType t, final String value, final ConstantPoolGen cpool) { - super(ElementValueGen.ENUM_CONSTANT, cpool); + super(ENUM_CONSTANT, cpool); typeIdx = cpool.addUtf8(t.getSignature()); // was addClass(t); valueIdx = cpool.addUtf8(value); // was addString(value); } From 4490737a60d44825f89e4ad3859ed4d9982ddfbd Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:49 -0400 Subject: [PATCH 047/114] Fix PMD UnnecessaryFullyQualifiedName --- .../apache/bcel/generic/ReferenceType.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/apache/bcel/generic/ReferenceType.java b/src/main/java/org/apache/bcel/generic/ReferenceType.java index 546bf0ae19..8fb838b2bd 100644 --- a/src/main/java/org/apache/bcel/generic/ReferenceType.java +++ b/src/main/java/org/apache/bcel/generic/ReferenceType.java @@ -38,10 +38,10 @@ protected ReferenceType(final byte t, final String s) { /** * This commutative operation returns the first common superclass (narrowest ReferenceType referencing a class, not an - * interface). If one of the types is a superclass of the other, the former is returned. If "this" is Type.NULL, then t - * is returned. If t is Type.NULL, then "this" is returned. If "this" equals t ['this.equals(t)'] "this" is returned. If - * "this" or t is an ArrayType, then Type.OBJECT is returned. If "this" or t is a ReferenceType referencing an - * interface, then Type.OBJECT is returned. If not all of the two classes' superclasses cannot be found, "null" is + * interface). If one of the types is a superclass of the other, the former is returned. If "this" is NULL, then t + * is returned. If t is NULL, then "this" is returned. If "this" equals t ['this.equals(t)'] "this" is returned. If + * "this" or t is an ArrayType, then {@link #OBJECT} is returned. If "this" or t is a ReferenceType referencing an + * interface, then {@link #OBJECT} is returned. If not all of the two classes' superclasses cannot be found, "null" is * returned. See the JVM specification edition 2, "īŋŊ4.9.2 The Bytecode Verifier". * * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has slightly changed semantics. @@ -49,45 +49,45 @@ protected ReferenceType(final byte t, final String s) { */ @Deprecated public ReferenceType firstCommonSuperclass(final ReferenceType t) throws ClassNotFoundException { - if (this.equals(Type.NULL)) { + if (this.equals(NULL)) { return t; } - if (t.equals(Type.NULL) || this.equals(t)) { + if (t.equals(NULL) || this.equals(t)) { return this; /* - * TODO: Above sounds a little arbitrary. On the other hand, there is no object referenced by Type.NULL so we can also - * say all the objects referenced by Type.NULL were derived from {@link Object}. However, the Java Language's + * TODO: Above sounds a little arbitrary. On the other hand, there is no object referenced by {@link #NULL} so we can also + * say all the objects referenced by {@link #NULL} were derived from {@link Object}. However, the Java Language's * "instanceof" operator proves us wrong: "null" is not referring to an instance of {@link Object} :) */ } if (this instanceof ArrayType || t instanceof ArrayType) { - return Type.OBJECT; - // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType? + return OBJECT; + // TODO: Is there a proof of {@link #OBJECT} being the direct ancestor of every ArrayType? } return getFirstCommonSuperclassInternal(t); } /** * This commutative operation returns the first common superclass (narrowest ReferenceType referencing a class, not an - * interface). If one of the types is a superclass of the other, the former is returned. If "this" is Type.NULL, then t - * is returned. If t is Type.NULL, then "this" is returned. If "this" equals t ['this.equals(t)'] "this" is returned. If - * "this" or t is an ArrayType, then Type.OBJECT is returned; unless their dimensions match. Then an ArrayType of the + * interface). If one of the types is a superclass of the other, the former is returned. If "this" is NULL, then t + * is returned. If t is NULL, then "this" is returned. If "this" equals t ['this.equals(t)'] "this" is returned. If + * "this" or t is an ArrayType, then {@link #OBJECT} is returned; unless their dimensions match. Then an ArrayType of the * same number of dimensions is returned, with its basic type being the first common super class of the basic types of - * "this" and t. If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned. If not all of + * "this" and t. If "this" or t is a ReferenceType referencing an interface, then {@link #OBJECT} is returned. If not all of * the two classes' superclasses cannot be found, "null" is returned. See the JVM specification edition 2, "īŋŊ4.9.2 The * Bytecode Verifier". * * @throws ClassNotFoundException on failure to find superclasses of this type, or the type passed as a parameter */ public ReferenceType getFirstCommonSuperclass(final ReferenceType t) throws ClassNotFoundException { - if (this.equals(Type.NULL)) { + if (this.equals(NULL)) { return t; } - if (t.equals(Type.NULL) || this.equals(t)) { + if (t.equals(NULL) || this.equals(t)) { return this; /* - * TODO: Above sounds a little arbitrary. On the other hand, there is no object referenced by Type.NULL so we can also - * say all the objects referenced by Type.NULL were derived from {@link Object}. However, the Java Language's + * TODO: Above sounds a little arbitrary. On the other hand, there is no object referenced by {@link #NULL} so we can also + * say all the objects referenced by {@link #NULL} were derived from {@link Object}. However, the Java Language's * "instanceof" operator proves us wrong: "null" is not referring to an instance of {@link Object} :) */ } @@ -102,8 +102,8 @@ public ReferenceType getFirstCommonSuperclass(final ReferenceType t) throws Clas } } if (this instanceof ArrayType || t instanceof ArrayType) { - return Type.OBJECT; - // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType? + return OBJECT; + // TODO: Is there a proof of {@link #OBJECT} being the direct ancestor of every ArrayType? } return getFirstCommonSuperclassInternal(t); } @@ -111,7 +111,7 @@ public ReferenceType getFirstCommonSuperclass(final ReferenceType t) throws Clas private ReferenceType getFirstCommonSuperclassInternal(final ReferenceType t) throws ClassNotFoundException { if (this instanceof ObjectType && ((ObjectType) this).referencesInterfaceExact() || t instanceof ObjectType && ((ObjectType) t).referencesInterfaceExact()) { - return Type.OBJECT; + return OBJECT; // TODO: The above line is correct comparing to the vmspec2. But one could // make class file verification a bit stronger here by using the notion of // superinterfaces or even castability or assignment compatibility. @@ -138,7 +138,7 @@ private ReferenceType getFirstCommonSuperclassInternal(final ReferenceType t) th } } } - // Huh? Did you ask for Type.OBJECT's superclass?? + // Huh? Did you ask for OBJECT's superclass?? return null; } @@ -154,7 +154,7 @@ public boolean isAssignmentCompatibleWith(final Type t) throws ClassNotFoundExce return false; } final ReferenceType T = (ReferenceType) t; - if (this.equals(Type.NULL)) { + if (this.equals(NULL)) { return true; // This is not explicitly stated, but clear. Isn't it? } /* @@ -183,7 +183,7 @@ public boolean isAssignmentCompatibleWith(final Type t) throws ClassNotFoundExce /* * If T is a class type, then T must be Object (īŋŊ2.4.7). */ - if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact() && T.equals(Type.OBJECT)) { + if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact() && T.equals(OBJECT)) { return true; } /* @@ -201,7 +201,7 @@ public boolean isAssignmentCompatibleWith(final Type t) throws ClassNotFoundExce /* * If T is a class type, then T must be Object (īŋŊ2.4.7). */ - if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact() && T.equals(Type.OBJECT)) { + if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact() && T.equals(OBJECT)) { return true; } /* @@ -242,14 +242,14 @@ public boolean isAssignmentCompatibleWith(final Type t) throws ClassNotFoundExce /** * Return true iff this type is castable to another type t as defined in the JVM specification. The case where this is - * Type.NULL is not defined (see the CHECKCAST definition in the JVM specification). However, because e.g. CHECKCAST + * {@link #NULL} is not defined (see the CHECKCAST definition in the JVM specification). However, because e.g. CHECKCAST * doesn't throw a ClassCastException when casting a null reference to any Object, true is returned in this case. * * @throws ClassNotFoundException if any classes or interfaces required to determine assignment compatibility can't be * found */ public boolean isCastableTo(final Type t) throws ClassNotFoundException { - if (this.equals(Type.NULL)) { + if (this.equals(NULL)) { return t instanceof ReferenceType; // If this is ever changed in isAssignmentCompatible() } return isAssignmentCompatibleWith(t); From e1af19f1c3c20bac0298b4568c8cc3817f2e0149 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:49 -0400 Subject: [PATCH 048/114] Fix PMD UnnecessaryFullyQualifiedName --- src/main/java/org/apache/bcel/generic/Type.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/bcel/generic/Type.java b/src/main/java/org/apache/bcel/generic/Type.java index 76b833907f..668f12cd40 100644 --- a/src/main/java/org/apache/bcel/generic/Type.java +++ b/src/main/java/org/apache/bcel/generic/Type.java @@ -158,7 +158,7 @@ public static Type getReturnType(final String signature) { static int getReturnTypeSize(final String signature) { final int index = signature.lastIndexOf(')') + 1; - return Type.size(getTypeSize(signature.substring(index))); + return size(getTypeSize(signature.substring(index))); } public static String getSignature(final java.lang.reflect.Method meth) { @@ -385,14 +385,14 @@ public int hashCode() { } /** - * boolean, short and char variable are considered as int in the stack or local variable area. Returns {@link Type#INT} - * for {@link Type#BOOLEAN}, {@link Type#SHORT} or {@link Type#CHAR}, otherwise returns the given type. + * boolean, short and char variable are considered as int in the stack or local variable area. Returns {@link #INT} + * for {@link #BOOLEAN}, {@link #SHORT} or {@link #CHAR}, otherwise returns the given type. * * @since 6.0 */ public Type normalizeForStackOrLocal() { - if (this == Type.BOOLEAN || this == Type.BYTE || this == Type.SHORT || this == Type.CHAR) { - return Type.INT; + if (this == BOOLEAN || this == BYTE || this == SHORT || this == CHAR) { + return INT; } return this; } @@ -402,6 +402,6 @@ public Type normalizeForStackOrLocal() { */ @Override public String toString() { - return this.equals(Type.NULL) || type >= Const.T_UNKNOWN ? signature : Utility.signatureToString(signature, false); + return this.equals(NULL) || type >= Const.T_UNKNOWN ? signature : Utility.signatureToString(signature, false); } } From a2f5baf97c9087f4e893469b485087d89cddf0a3 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:49:50 -0400 Subject: [PATCH 049/114] Fix PMD UnnecessaryFullyQualifiedName --- src/main/java/org/apache/bcel/verifier/VerifyDialog.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/apache/bcel/verifier/VerifyDialog.java b/src/main/java/org/apache/bcel/verifier/VerifyDialog.java index 88ef3b3ffd..5427bcc332 100644 --- a/src/main/java/org/apache/bcel/verifier/VerifyDialog.java +++ b/src/main/java/org/apache/bcel/verifier/VerifyDialog.java @@ -29,7 +29,6 @@ import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JPanel; -import javax.swing.WindowConstants; import org.apache.bcel.Repository; import org.apache.bcel.classfile.JavaClass; @@ -464,7 +463,7 @@ private void initialize() { // user code begin {1} // user code end setName("VerifyDialog"); - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + setDefaultCloseOperation(DISPOSE_ON_CLOSE); setSize(430, 280); setVisible(true); setModal(true); From fcd825ceb06c81e1deb3c96fa7b965fa9ebdf242 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:51:15 -0400 Subject: [PATCH 050/114] Fix PMD UnnecessaryFullyQualifiedName --- src/changes/changes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7de9b4236c..36f203c059 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -61,6 +61,7 @@ The type attribute can be add,update,fix,remove. + Fix PMD UnnecessaryFullyQualifiedName. Add accessors to model and unit tests, Javadoc #183. From 7ad8772178feb4fac548543c891090d40c9f6002 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 08:56:53 -0400 Subject: [PATCH 051/114] Fix PMD EmptyCatchBlock by allowing commented blocks Fix PMD EmptyControlStatement by allowing commented blocks --- src/changes/changes.xml | 2 ++ src/conf/pmd-ruleset.xml | 19 ++++++++++++------- .../bcel/classfile/BootstrapMethod.java | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 36f203c059..f6498fc3be 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -62,6 +62,8 @@ The type attribute can be add,update,fix,remove. Fix PMD UnnecessaryFullyQualifiedName. + Fix PMD EmptyCatchBlock by allowing commented blocks. + Fix PMD EmptyControlStatement by allowing commented blocks. Add accessors to model and unit tests, Javadoc #183. diff --git a/src/conf/pmd-ruleset.xml b/src/conf/pmd-ruleset.xml index 9cafbb480d..89eb9b8d2b 100644 --- a/src/conf/pmd-ruleset.xml +++ b/src/conf/pmd-ruleset.xml @@ -19,11 +19,9 @@ xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> - This ruleset checks the code for discouraged programming constructs. - @@ -32,7 +30,6 @@ - @@ -54,7 +51,6 @@ - @@ -67,9 +63,7 @@ - - + + + + + + + + + + + diff --git a/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java b/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java index ff4b93b01a..32d2acfcec 100644 --- a/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java +++ b/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java @@ -86,7 +86,7 @@ public BootstrapMethod(final int bootstrapMethodRef, final int[] bootstrapArgume public BootstrapMethod copy() { try { return (BootstrapMethod) clone(); - } catch (final CloneNotSupportedException e) { + } catch (final CloneNotSupportedException ignore) { // TODO should this throw? } return null; From a8e156d92612433be3ae300a83719355f459b67b Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 09:00:52 -0400 Subject: [PATCH 052/114] Fix SpotBugs RV_RETURN_VALUE_IGNORED_BAD_PRACTICE in JasminVisitor --- src/changes/changes.xml | 1 + src/examples/JasminVisitor.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f6498fc3be..fb77982bbb 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -64,6 +64,7 @@ The type attribute can be add,update,fix,remove. Fix PMD UnnecessaryFullyQualifiedName. Fix PMD EmptyCatchBlock by allowing commented blocks. Fix PMD EmptyControlStatement by allowing commented blocks. + Fix SpotBugs RV_RETURN_VALUE_IGNORED_BAD_PRACTICE in JasminVisitor. Add accessors to model and unit tests, Javadoc #183. diff --git a/src/examples/JasminVisitor.java b/src/examples/JasminVisitor.java index 16ef15c55b..eafc548b2e 100644 --- a/src/examples/JasminVisitor.java +++ b/src/examples/JasminVisitor.java @@ -73,8 +73,10 @@ public static void main(final String[] argv) throws Exception { className = className.substring(index + 1); if (!path.isEmpty()) { - final File f = new File(path); - f.mkdirs(); + final File file = new File(path); + if (!file.mkdirs()) { + System.err.println("Couldn't create directories for " + file); + } } final String name = path + className + ".j"; From cffcf789312035b3f56b290951acfc79cd4bdb66 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 09:06:13 -0400 Subject: [PATCH 053/114] Clearer private instance variable names --- src/examples/JasminVisitor.java | 84 ++++++++++++++++----------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/examples/JasminVisitor.java b/src/examples/JasminVisitor.java index eafc548b2e..03c2fe52e2 100644 --- a/src/examples/JasminVisitor.java +++ b/src/examples/JasminVisitor.java @@ -87,19 +87,19 @@ public static void main(final String[] argv) throws Exception { } } - private final JavaClass clazz; - private final PrintWriter out; + private final JavaClass javaClass; + private final PrintWriter printWriter; private final String className; private final ConstantPoolGen cp; - private Method _method; + private Method method; private Hashtable map; public JasminVisitor(final JavaClass clazz, final OutputStream out) { - this.clazz = clazz; - this.out = new PrintWriter(out); + this.javaClass = clazz; + this.printWriter = new PrintWriter(out); this.className = clazz.getClassName(); this.cp = new ConstantPoolGen(clazz.getConstantPool()); } @@ -108,8 +108,8 @@ public JasminVisitor(final JavaClass clazz, final OutputStream out) { * Start traversal using DefaultVisitor pattern. */ public void disassemble() { - new org.apache.bcel.classfile.DescendingVisitor(clazz, this).visit(); - out.close(); + new org.apache.bcel.classfile.DescendingVisitor(javaClass, this).visit(); + printWriter.close(); } private String get(final InstructionHandle ih) { @@ -122,10 +122,10 @@ private String get(final InstructionHandle ih) { * attributes if it's the last one and print ".end method" then. */ private void printEndMethod(final Attribute attr) { - final Attribute[] attributes = _method.getAttributes(); + final Attribute[] attributes = method.getAttributes(); if (attr == attributes[attributes.length - 1]) { - out.println(".end method"); + printWriter.println(".end method"); } } @@ -147,10 +147,10 @@ private void put(final InstructionHandle ih, final String line) { public void visitCode(final Code code) { int labelCounter = 0; - out.println(".limit stack " + code.getMaxStack()); - out.println(".limit locals " + code.getMaxLocals()); + printWriter.println(".limit stack " + code.getMaxStack()); + printWriter.println(".limit locals " + code.getMaxLocals()); - final MethodGen mg = new MethodGen(_method, className, cp); + final MethodGen mg = new MethodGen(method, className, cp); final InstructionList il = mg.getInstructionList(); final InstructionHandle[] ihs = il.getInstructionHandles(); @@ -201,18 +201,18 @@ public void visitCode(final Code code) { // Pass 2: Output code. for (final LocalVariableGen l : lvs) { - out.println( + printWriter.println( ".var " + l.getIndex() + " is " + l.getName() + " " + l.getType().getSignature() + " from " + get(l.getStart()) + " to " + get(l.getEnd())); } - out.print("\n"); + printWriter.print("\n"); for (InstructionHandle ih : ihs) { final Instruction inst = ih.getInstruction(); String str = map.get(ih); if (str != null) { - out.println(str); + printWriter.println(str); } if (inst instanceof BranchInstruction) { @@ -222,40 +222,40 @@ public void visitCode(final Code code) { final InstructionHandle[] targets = s.getTargets(); if (s instanceof TABLESWITCH) { - out.println("\ttableswitch " + matchs[0] + " " + matchs[matchs.length - 1]); + printWriter.println("\ttableswitch " + matchs[0] + " " + matchs[matchs.length - 1]); for (final InstructionHandle target : targets) { - out.println("\t\t" + get(target)); + printWriter.println("\t\t" + get(target)); } } else { // LOOKUPSWITCH - out.println("\tlookupswitch "); + printWriter.println("\tlookupswitch "); for (int j = 0; j < targets.length; j++) { - out.println("\t\t" + matchs[j] + " : " + get(targets[j])); + printWriter.println("\t\t" + matchs[j] + " : " + get(targets[j])); } } - out.println("\t\tdefault: " + get(s.getTarget())); // Applies for both + printWriter.println("\t\tdefault: " + get(s.getTarget())); // Applies for both } else { final BranchInstruction bi = (BranchInstruction) inst; ih = bi.getTarget(); str = get(ih); - out.println("\t" + Const.getOpcodeName(bi.getOpcode()) + " " + str); + printWriter.println("\t" + Const.getOpcodeName(bi.getOpcode()) + " " + str); } } else { - out.println("\t" + inst.toString(cp.getConstantPool())); + printWriter.println("\t" + inst.toString(cp.getConstantPool())); } } - out.print("\n"); + printWriter.print("\n"); for (final CodeExceptionGen c : ehs) { final ObjectType caught = c.getCatchType(); final String className = caught == null ? // catch any exception, used when compiling finally "all" : Utility.packageToPath(caught.getClassName()); - out.println(".catch " + className + " from " + get(c.getStartPC()) + " to " + get(c.getEndPC()) + " using " + get(c.getHandlerPC())); + printWriter.println(".catch " + className + " from " + get(c.getStartPC()) + " to " + get(c.getEndPC()) + " using " + get(c.getHandlerPC())); } printEndMethod(code); @@ -263,7 +263,7 @@ public void visitCode(final Code code) { @Override public void visitConstantValue(final ConstantValue cv) { - out.println(" = " + cv); + printWriter.println(" = " + cv); } @Override @@ -274,7 +274,7 @@ public void visitDeprecated(final Deprecated attribute) { @Override public void visitExceptionTable(final ExceptionTable e) { for (final String name : e.getExceptionNames()) { - out.println(".throws " + Utility.packageToPath(name)); + printWriter.println(".throws " + Utility.packageToPath(name)); } printEndMethod(e); @@ -282,45 +282,45 @@ public void visitExceptionTable(final ExceptionTable e) { @Override public void visitField(final Field field) { - out.print(".field " + Utility.accessToString(field.getAccessFlags()) + " \"" + field.getName() + "\"" + field.getSignature()); + printWriter.print(".field " + Utility.accessToString(field.getAccessFlags()) + " \"" + field.getName() + "\"" + field.getSignature()); if (field.getAttributes().length == 0) { - out.print("\n"); + printWriter.print("\n"); } } @Override public void visitJavaClass(final JavaClass clazz) { - out.println(";; Produced by JasminVisitor (BCEL)"); - out.println(";; https://commons.apache.org/bcel/"); - out.println(";; " + new Date() + "\n"); + printWriter.println(";; Produced by JasminVisitor (BCEL)"); + printWriter.println(";; https://commons.apache.org/bcel/"); + printWriter.println(";; " + new Date() + "\n"); - out.println(".source " + clazz.getSourceFileName()); - out.println("." + Utility.classOrInterface(clazz.getAccessFlags()) + " " + Utility.accessToString(clazz.getAccessFlags(), true) + " " + printWriter.println(".source " + clazz.getSourceFileName()); + printWriter.println("." + Utility.classOrInterface(clazz.getAccessFlags()) + " " + Utility.accessToString(clazz.getAccessFlags(), true) + " " + Utility.packageToPath(clazz.getClassName())); - out.println(".super " + Utility.packageToPath(clazz.getSuperclassName())); + printWriter.println(".super " + Utility.packageToPath(clazz.getSuperclassName())); for (final String iface : clazz.getInterfaceNames()) { - out.println(".implements " + Utility.packageToPath(iface)); + printWriter.println(".implements " + Utility.packageToPath(iface)); } - out.print("\n"); + printWriter.print("\n"); } @Override - public void visitMethod(final Method method) { - this._method = method; // Remember for use in subsequent visitXXX calls + public void visitMethod(final Method visitMethod) { + this.method = visitMethod; // Remember for use in subsequent visitXXX calls - out.println("\n.method " + Utility.accessToString(_method.getAccessFlags()) + " " + _method.getName() + _method.getSignature()); + printWriter.println("\n.method " + Utility.accessToString(method.getAccessFlags()) + " " + method.getName() + method.getSignature()); - final Attribute[] attributes = _method.getAttributes(); + final Attribute[] attributes = method.getAttributes(); if (attributes == null || attributes.length == 0) { - out.println(".end method"); + printWriter.println(".end method"); } } @Override public void visitSynthetic(final Synthetic attribute) { - if (_method != null) { + if (method != null) { printEndMethod(attribute); } } From c9473daf0985c0929e4bb55d4350ea267ff560d3 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 09:24:40 -0400 Subject: [PATCH 054/114] Fix spelling --- src/examples/Mini/ASTExpr.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/examples/Mini/ASTExpr.java b/src/examples/Mini/ASTExpr.java index 03b31f13ec..124c8185b0 100644 --- a/src/examples/Mini/ASTExpr.java +++ b/src/examples/Mini/ASTExpr.java @@ -41,7 +41,7 @@ * * A node with kind == -1 denotes the fact that this expression node has just one child branch and thus may be replaced * by this branch (or leaf) directly without altering the expression semantics. Term and Factor nodes are used only to - * build the parse tree obeying the aritmetical precedences (* stronger than +, etc.) and are discarded in the first + * build the parse tree obeying the arithmetical precedences (* stronger than +, etc.) and are discarded in the first * pass. */ public class ASTExpr extends SimpleNode implements MiniParserConstants, MiniParserTreeConstants { From 93cf33999670ffc0d0f8131d7609eb0b04905d90 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 09:27:40 -0400 Subject: [PATCH 055/114] SpotBugs checks should ignore code generated by JavaCC --- src/changes/changes.xml | 1 + src/conf/spotbugs-exclude-filter.xml | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index fb77982bbb..ab3cf2d317 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -65,6 +65,7 @@ The type attribute can be add,update,fix,remove. Fix PMD EmptyCatchBlock by allowing commented blocks. Fix PMD EmptyControlStatement by allowing commented blocks. Fix SpotBugs RV_RETURN_VALUE_IGNORED_BAD_PRACTICE in JasminVisitor. + SpotBugs checks should ignore code generated by JavaCC. Add accessors to model and unit tests, Javadoc #183. diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml index f917b60c7f..ba6af8cd42 100644 --- a/src/conf/spotbugs-exclude-filter.xml +++ b/src/conf/spotbugs-exclude-filter.xml @@ -154,4 +154,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + From 581b303b6751769208dc9f36a0300a9f22b0953f Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 09:29:22 -0400 Subject: [PATCH 056/114] Fix SpotBugs URF_UNREAD_FIELD in ClassDumper --- src/changes/changes.xml | 1 + src/examples/ClassDumper.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index ab3cf2d317..da301fb4ee 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -66,6 +66,7 @@ The type attribute can be add,update,fix,remove. Fix PMD EmptyControlStatement by allowing commented blocks. Fix SpotBugs RV_RETURN_VALUE_IGNORED_BAD_PRACTICE in JasminVisitor. SpotBugs checks should ignore code generated by JavaCC. + Fix SpotBugs URF_UNREAD_FIELD in ClassDumper. Add accessors to model and unit tests, Javadoc #183. diff --git a/src/examples/ClassDumper.java b/src/examples/ClassDumper.java index 6ebaaab9bb..4822dd7fb9 100644 --- a/src/examples/ClassDumper.java +++ b/src/examples/ClassDumper.java @@ -44,8 +44,8 @@ final class ClassDumper { private int[] interfaces; // Names of implemented interfaces private ConstantPool constantPool; // collection of constants private Constant[] constantItems; // collection of constants - private Field[] fields; // class fields, i.e., its variables - private Method[] methods; // methods defined in the class + // private Field[] fields; // class fields, i.e., its variables + // private Method[] methods; // methods defined in the class private Attribute[] attributes; // attributes defined in the class /** @@ -249,7 +249,7 @@ private final void processFieldOrMethod() throws IOException, ClassFormatExcepti */ private final void processFields() throws IOException, ClassFormatException { final int fieldsCount = file.readUnsignedShort(); - fields = new Field[fieldsCount]; + // fields = new Field[fieldsCount]; // sometimes fields[0] is magic used for serialization System.out.printf("%nFields(%d):%n", fieldsCount); @@ -313,7 +313,7 @@ private final void processInterfaces() throws IOException, ClassFormatException */ private final void processMethods() throws IOException, ClassFormatException { final int methodsCount = file.readUnsignedShort(); - methods = new Method[methodsCount]; + // methods = new Method[methodsCount]; System.out.printf("%nMethods(%d):%n", methodsCount); From 2a5992ff8f81998931a47b3bdf104e4f623a8f95 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 09:35:11 -0400 Subject: [PATCH 057/114] Fix SpotBugs DM_DEFAULT_ENCODING in JasminVisitor --- src/changes/changes.xml | 1 + src/examples/JasminVisitor.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index da301fb4ee..3485b1b091 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -67,6 +67,7 @@ The type attribute can be add,update,fix,remove. Fix SpotBugs RV_RETURN_VALUE_IGNORED_BAD_PRACTICE in JasminVisitor. SpotBugs checks should ignore code generated by JavaCC. Fix SpotBugs URF_UNREAD_FIELD in ClassDumper. + Fix SpotBugs DM_DEFAULT_ENCODING in JasminVisitor. Add accessors to model and unit tests, Javadoc #183. diff --git a/src/examples/JasminVisitor.java b/src/examples/JasminVisitor.java index 03c2fe52e2..d17a3528e7 100644 --- a/src/examples/JasminVisitor.java +++ b/src/examples/JasminVisitor.java @@ -15,10 +15,13 @@ * limitations under the License. */ +import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.Hashtable; import java.util.StringTokenizer; @@ -99,7 +102,7 @@ public static void main(final String[] argv) throws Exception { public JasminVisitor(final JavaClass clazz, final OutputStream out) { this.javaClass = clazz; - this.printWriter = new PrintWriter(out); + this.printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8)), false); this.className = clazz.getClassName(); this.cp = new ConstantPoolGen(clazz.getConstantPool()); } From 2b3c043388074407cd05acc0e97b89f58efbed00 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 09:39:56 -0400 Subject: [PATCH 058/114] Fix SpotBugs RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE in ASTFunAppl --- src/changes/changes.xml | 1 + src/examples/Mini/ASTFunAppl.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 3485b1b091..353b07e500 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -68,6 +68,7 @@ The type attribute can be add,update,fix,remove. SpotBugs checks should ignore code generated by JavaCC. Fix SpotBugs URF_UNREAD_FIELD in ClassDumper. Fix SpotBugs DM_DEFAULT_ENCODING in JasminVisitor. + Fix SpotBugs RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE in ASTFunAppl. Add accessors to model and unit tests, Javadoc #183. diff --git a/src/examples/Mini/ASTFunAppl.java b/src/examples/Mini/ASTFunAppl.java index d5e9a4756d..95c04b3737 100644 --- a/src/examples/Mini/ASTFunAppl.java +++ b/src/examples/Mini/ASTFunAppl.java @@ -25,6 +25,7 @@ import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.MethodGen; import org.apache.bcel.generic.Type; +import org.apache.commons.lang3.ArrayUtils; /** */ @@ -72,7 +73,7 @@ public void byte_code(final InstructionList il, final MethodGen method, final Co ASTFunDecl.pop(); il.append(new INVOKESTATIC(cp.addMethodref(className, "_writeInt", "(I)I"))); } else { // Normal function - final int size = exprs.length; + final int size = ArrayUtils.getLength(exprs); Type[] argv = null; if (exprs != null) { From e09e09641daf7dc9888b0014b1bbc2680bcbf19d Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 09:43:39 -0400 Subject: [PATCH 059/114] Fix compile --- src/examples/Mini/ASTFunDecl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/examples/Mini/ASTFunDecl.java b/src/examples/Mini/ASTFunDecl.java index 2a3fadf591..6002a168c9 100644 --- a/src/examples/Mini/ASTFunDecl.java +++ b/src/examples/Mini/ASTFunDecl.java @@ -317,7 +317,7 @@ public void code(final PrintWriter out) { } if (!ignore) { - final StringBuilder buf = new StringBuilder(); + final StringBuffer buf = new StringBuffer(); body.code(buf); out.println(getVarDecls()); From 8f26b8ee0287fea0707e9fef2aae1bdcd5304006 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 09:47:17 -0400 Subject: [PATCH 060/114] Updates for current version of SpotBugs --- src/conf/spotbugs-exclude-filter.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml index ba6af8cd42..f6ae0dd1fb 100644 --- a/src/conf/spotbugs-exclude-filter.xml +++ b/src/conf/spotbugs-exclude-filter.xml @@ -178,5 +178,8 @@ - + + + + From 07b48ca4cd456112afd2c1b54a849d8a850d58b9 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 10:23:50 -0400 Subject: [PATCH 061/114] Javadoc --- .../java/org/apache/bcel/generic/InstructionTargeter.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/bcel/generic/InstructionTargeter.java b/src/main/java/org/apache/bcel/generic/InstructionTargeter.java index f958a25e73..99a0b85d89 100644 --- a/src/main/java/org/apache/bcel/generic/InstructionTargeter.java +++ b/src/main/java/org/apache/bcel/generic/InstructionTargeter.java @@ -29,9 +29,12 @@ public interface InstructionTargeter { // static final InstructionTargeter[] EMPTY_ARRAY = new InstructionTargeter[0]; /** - * Checks whether this targeter targets the specified instruction handle. + * Tests whether this targeter targets the specified instruction handle. + * + * @param instructionHandle the instruction handle to test. + * @return whether this targeter targets the specified instruction handle. */ - boolean containsTarget(InstructionHandle ih); + boolean containsTarget(InstructionHandle instructionHandle); /** * Replaces the target of this targeter from this old handle to the new handle. From 9260aa4ce2150f4096fe0b5d061c38971d1d53c7 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 10:24:26 -0400 Subject: [PATCH 062/114] Javadoc --- src/main/java/org/apache/bcel/generic/InstructionTargeter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/generic/InstructionTargeter.java b/src/main/java/org/apache/bcel/generic/InstructionTargeter.java index 99a0b85d89..856cd611b9 100644 --- a/src/main/java/org/apache/bcel/generic/InstructionTargeter.java +++ b/src/main/java/org/apache/bcel/generic/InstructionTargeter.java @@ -18,7 +18,7 @@ package org.apache.bcel.generic; /** - * Denote that a class targets InstructionHandles within an InstructionList. Namely the following implementers: + * Denotes that a class targets InstructionHandles within an InstructionList. * * @see BranchHandle * @see LocalVariableGen From bb87fc578ec50d3eee3ac71b9f90dc92a8c22725 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 10:29:37 -0400 Subject: [PATCH 063/114] Javadoc Better parameter name --- .../bcel/generic/TargetLostException.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/apache/bcel/generic/TargetLostException.java b/src/main/java/org/apache/bcel/generic/TargetLostException.java index 94abf59415..1fb3bf80ec 100644 --- a/src/main/java/org/apache/bcel/generic/TargetLostException.java +++ b/src/main/java/org/apache/bcel/generic/TargetLostException.java @@ -17,16 +17,16 @@ package org.apache.bcel.generic; /** - * Thrown by InstructionList.remove() when one or multiple disposed instructions are still being referenced by an - * InstructionTargeter object. I.e. the InstructionTargeter has to be notified that (one of) the InstructionHandle it is - * referencing is being removed from the InstructionList and thus not valid anymore. + * Thrown by {@link InstructionList} when one or multiple disposed instructions are still being referenced by an {@link InstructionTargeter} object. I.e. the + * {@link InstructionTargeter} has to be notified that (one of) the {@link InstructionHandle} it is referencing is being removed from the + * {@link InstructionList} and thus not valid anymore. * *

- * Making this an exception instead of a return value forces the user to handle these case explicitly in a try { ... } - * catch. The following code illustrates how this may be done: + * Making this an exception instead of a return value forces the user to handle these case explicitly in a try { ... } catch. The following code illustrates how + * this may be done: *

* - *
+ * 
  *     ...
  *     try {
  *         il.delete(start_ih, end_ih);
@@ -37,7 +37,7 @@
  *             }
  *         }
  *     }
- * 
+ *
* * @see InstructionHandle * @see InstructionList @@ -48,12 +48,14 @@ public final class TargetLostException extends Exception { private static final long serialVersionUID = -6857272667645328384L; private final InstructionHandle[] targets; - TargetLostException(final InstructionHandle[] t, final String mesg) { - super(mesg); - targets = t; + TargetLostException(final InstructionHandle[] targets, final String message) { + super(message); + this.targets = targets; } /** + * Gets the list of instructions still being targeted. + * * @return list of instructions still being targeted. */ public InstructionHandle[] getTargets() { From e4976ff4b8321fd0062b19b4ee8d1ddcb41f980c Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 10:32:35 -0400 Subject: [PATCH 064/114] Add SpotBugs TODO Is this really identity equality and not object equality? --- src/conf/spotbugs-exclude-filter.xml | 7 +++++++ src/examples/Mini/ASTFunDecl.java | 1 + 2 files changed, 8 insertions(+) diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml index f6ae0dd1fb..0de6c6555e 100644 --- a/src/conf/spotbugs-exclude-filter.xml +++ b/src/conf/spotbugs-exclude-filter.xml @@ -154,6 +154,13 @@ + + + + + + + diff --git a/src/examples/Mini/ASTFunDecl.java b/src/examples/Mini/ASTFunDecl.java index 6002a168c9..a3f246d7c5 100644 --- a/src/examples/Mini/ASTFunDecl.java +++ b/src/examples/Mini/ASTFunDecl.java @@ -111,6 +111,7 @@ private static void optimizeIFs(final InstructionList il) { final InstructionTargeter[] targeters = target.getTargeters(); for (final InstructionTargeter targeter : targeters) { + // TODO Is this really identity equality and not object equality? if (target != match[4] || targeter != match[2]) { System.err.println("Unexpected: " + e); } From bb53a5ba3c7cec5065b5072046c3da3cbe70a335 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 10:35:29 -0400 Subject: [PATCH 065/114] Comment out unused local variable --- src/examples/Mini/MiniC.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/examples/Mini/MiniC.java b/src/examples/Mini/MiniC.java index 62e3b9e2ae..af22535a32 100644 --- a/src/examples/Mini/MiniC.java +++ b/src/examples/Mini/MiniC.java @@ -66,7 +66,7 @@ final static String fillup(final int n, final int len) { public static void main(final String[] argv) { final String[] file_name = new String[argv.length]; int files = 0; - MiniParser parser = null; + // MiniParser parser = null; String base_name = null; boolean byte_code = true; @@ -98,7 +98,7 @@ public static void main(final String[] argv) { pass = 0; if (j == 0) { - parser = new MiniParser(new FileInputStream(file_name[0])); + // parser = new MiniParser(new FileInputStream(file_name[0])); } else { MiniParser.ReInit(new FileInputStream(file_name[j])); } From 4f7ad11d554f6c24ec3b352728816b1cd164d679 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 10:37:05 -0400 Subject: [PATCH 066/114] Normalize local variable names --- src/examples/Mini/MiniC.java | 46 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/examples/Mini/MiniC.java b/src/examples/Mini/MiniC.java index af22535a32..b56abc50d6 100644 --- a/src/examples/Mini/MiniC.java +++ b/src/examples/Mini/MiniC.java @@ -64,11 +64,11 @@ final static String fillup(final int n, final int len) { } public static void main(final String[] argv) { - final String[] file_name = new String[argv.length]; + final String[] fileName = new String[argv.length]; int files = 0; // MiniParser parser = null; - String base_name = null; - boolean byte_code = true; + String baseName = null; + boolean byteCode = true; try { /* @@ -77,14 +77,14 @@ public static void main(final String[] argv) { for (final String element : argv) { if (element.charAt(0) == '-') { // command line switch if (element.equals("-java")) { - byte_code = false; + byteCode = false; } else if (element.equals("-bytecode")) { - byte_code = true; + byteCode = true; } else { throw new Exception("Unknown option: " + element); } } else { // add file name to list - file_name[files++] = element; + fileName[files++] = element; } } @@ -98,23 +98,23 @@ public static void main(final String[] argv) { pass = 0; if (j == 0) { - // parser = new MiniParser(new FileInputStream(file_name[0])); + // parser = new MiniParser(new FileInputStream(fileName[0])); } else { - MiniParser.ReInit(new FileInputStream(file_name[j])); + MiniParser.ReInit(new FileInputStream(fileName[j])); } - int index = file_name[j].lastIndexOf('.'); + int index = fileName[j].lastIndexOf('.'); if (index > 0) { - base_name = file_name[j].substring(0, index); + baseName = fileName[j].substring(0, index); } else { - base_name = file_name[j]; + baseName = fileName[j]; } - if ((index = base_name.lastIndexOf(File.separatorChar)) > 0) { - base_name = base_name.substring(index + 1); + if ((index = baseName.lastIndexOf(File.separatorChar)) > 0) { + baseName = baseName.substring(index + 1); } - file = file_name[j]; + file = fileName[j]; System.out.println("Parsing ..."); MiniParser.Program(); @@ -140,24 +140,24 @@ public static void main(final String[] argv) { warnings.forEach(System.out::println); if (errors.isEmpty()) { - if (byte_code) { + if (byteCode) { System.out.println("Pass 5: Generating byte code ..."); - final ClassGen class_gen = new ClassGen(base_name, "java.lang.Object", file_name[j], + final ClassGen classGen = new ClassGen(baseName, "java.lang.Object", fileName[j], Const.ACC_PUBLIC | Const.ACC_FINAL | Const.ACC_SUPER, null); - final ConstantPoolGen cp = class_gen.getConstantPool(); + final ConstantPoolGen cp = classGen.getConstantPool(); - program.byte_code(class_gen, cp); - final JavaClass clazz = class_gen.getJavaClass(); - clazz.dump(base_name + JavaClass.EXTENSION); + program.byte_code(classGen, cp); + final JavaClass clazz = classGen.getJavaClass(); + clazz.dump(baseName + JavaClass.EXTENSION); } else { System.out.println("Pass 5: Generating Java code ..."); - try (final PrintWriter out = new PrintWriter(new FileOutputStream(base_name + ".java"))) { - program.code(out, base_name); + try (final PrintWriter out = new PrintWriter(new FileOutputStream(baseName + ".java"))) { + program.code(out, baseName); } System.out.println("Pass 6: Compiling Java code ..."); - final String[] args = { "javac", base_name + ".java" }; + final String[] args = { "javac", baseName + ".java" }; // sun.tools.javac.Main compiler = new sun.tools.javac.Main(System.err, "javac"); try { final Process p = Runtime.getRuntime().exec(args); From 523354d733e58772a7de073f625f9ec0f0523888 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 10:41:47 -0400 Subject: [PATCH 067/114] Adjust use of "..." in console messages --- src/examples/Mini/MiniC.java | 14 +++++++------- src/examples/PatchClass.java | 2 +- src/examples/ProxyCreator.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/examples/Mini/MiniC.java b/src/examples/Mini/MiniC.java index b56abc50d6..590e50a7d0 100644 --- a/src/examples/Mini/MiniC.java +++ b/src/examples/Mini/MiniC.java @@ -116,22 +116,22 @@ public static void main(final String[] argv) { file = fileName[j]; - System.out.println("Parsing ..."); + System.out.println("Parsing..."); MiniParser.Program(); ASTProgram program = (ASTProgram) MiniParser.jjtree.rootNode(); - System.out.println("Pass 1: Optimizing parse tree ..."); + System.out.println("Pass 1: Optimizing parse tree..."); pass = 1; program = program.traverse(); // program.dump(">"); if (errors.isEmpty()) { - System.out.println("Pass 2: Type checking (I) ..."); + System.out.println("Pass 2: Type checking (I)..."); program.eval(pass = 2); } if (errors.isEmpty()) { - System.out.println("Pass 3: Type checking (II) ..."); + System.out.println("Pass 3: Type checking (II)..."); program.eval(pass = 3); } @@ -141,7 +141,7 @@ public static void main(final String[] argv) { if (errors.isEmpty()) { if (byteCode) { - System.out.println("Pass 5: Generating byte code ..."); + System.out.println("Pass 5: Generating byte code..."); final ClassGen classGen = new ClassGen(baseName, "java.lang.Object", fileName[j], Const.ACC_PUBLIC | Const.ACC_FINAL | Const.ACC_SUPER, null); final ConstantPoolGen cp = classGen.getConstantPool(); @@ -150,12 +150,12 @@ public static void main(final String[] argv) { final JavaClass clazz = classGen.getJavaClass(); clazz.dump(baseName + JavaClass.EXTENSION); } else { - System.out.println("Pass 5: Generating Java code ..."); + System.out.println("Pass 5: Generating Java code..."); try (final PrintWriter out = new PrintWriter(new FileOutputStream(baseName + ".java"))) { program.code(out, baseName); } - System.out.println("Pass 6: Compiling Java code ..."); + System.out.println("Pass 6: Compiling Java code..."); final String[] args = { "javac", baseName + ".java" }; // sun.tools.javac.Main compiler = new sun.tools.javac.Main(System.err, "javac"); diff --git a/src/examples/PatchClass.java b/src/examples/PatchClass.java index d1c4b2967e..8e3da974a9 100644 --- a/src/examples/PatchClass.java +++ b/src/examples/PatchClass.java @@ -32,7 +32,7 @@ public static void main(final String[] argv) throws Exception { int files = 0; if (argv.length < 3) { - System.err.println("Usage: patch file1.class ..."); + System.err.println("Usage: patch file1.class..."); System.exit(-1); } diff --git a/src/examples/ProxyCreator.java b/src/examples/ProxyCreator.java index 995f607191..0dde45fe2d 100644 --- a/src/examples/ProxyCreator.java +++ b/src/examples/ProxyCreator.java @@ -116,7 +116,7 @@ public static void main(final String[] argv) throws Exception { final String s = Utility.encode(bytes, true); System.out.println("Encoded class: " + s.length()); - System.out.print("Creating proxy ... "); + System.out.print("Creating proxy... "); final ActionListener a = (ActionListener) createProxy("foo.bar.", s); System.out.println("Done. Now calling actionPerformed()"); From c60228067a46999aa39f9b3ecc6f523fbda3e3c5 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 10:47:17 -0400 Subject: [PATCH 068/114] Account for side-effects --- src/examples/Mini/MiniC.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/examples/Mini/MiniC.java b/src/examples/Mini/MiniC.java index 590e50a7d0..d9ee6a2725 100644 --- a/src/examples/Mini/MiniC.java +++ b/src/examples/Mini/MiniC.java @@ -20,6 +20,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.PrintWriter; +import java.util.Objects; import java.util.Vector; import org.apache.bcel.Const; @@ -65,9 +66,10 @@ final static String fillup(final int n, final int len) { public static void main(final String[] argv) { final String[] fileName = new String[argv.length]; + int files = 0; - // MiniParser parser = null; - String baseName = null; + MiniParser parser; + String baseName; boolean byteCode = true; try { @@ -98,7 +100,9 @@ public static void main(final String[] argv) { pass = 0; if (j == 0) { - // parser = new MiniParser(new FileInputStream(fileName[0])); + // side-effects + parser = new MiniParser(new FileInputStream(fileName[0])); + Objects.requireNonNull(parser, "parser"); } else { MiniParser.ReInit(new FileInputStream(fileName[j])); } From 195ed0ffba4fd0aa9f379a75f794207e05b6953d Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 11:11:06 -0400 Subject: [PATCH 069/114] Redo Mini.Environment a la Java 8 --- src/examples/Mini/Environment.java | 154 +++-------------------------- 1 file changed, 16 insertions(+), 138 deletions(-) diff --git a/src/examples/Mini/Environment.java b/src/examples/Mini/Environment.java index 3913e0a572..49c36833b3 100644 --- a/src/examples/Mini/Environment.java +++ b/src/examples/Mini/Environment.java @@ -16,96 +16,44 @@ */ package Mini; -import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; /** * For efficiency and convenience reasons we want our own hash table. It does not conform to java.util.Dictionary(yet). * - * That environment contains all function definitions and identifiers. Hash keys are Strings (identifiers), which are - * mapped to a table index. + * That environment contains all function definitions and identifiers. Hash keys are Strings (identifiers), which are mapped to a table index. * - * The table consists of 'SIZE' fields which have 'SLOTS' subfields. Thus the maximum number of storable items is - * 'SLOTS' * 'SIZE'. + * The table consists of 'SIZE' fields which have 'SLOTS' subfields. Thus the maximum number of storable items is 'SLOTS' * 'SIZE'. */ public class Environment implements Cloneable { - private static final int SIZE = 127; // Prime number large enough for most cases - private static final int SLOTS = 3; // Number of slots of each field - - private static int lookup(final Vector v, final String key) throws ArrayIndexOutOfBoundsException { - final int len = v.size(); - - for (int i = 0; i < len; i++) { - final EnvEntry entry = v.elementAt(i); - - if (entry.getHashKey().equals(key)) { - return i; - } - } - return -1; - } - - private final int size; // The table is an array of - private final Vector[] table; // Vectors + private static final int SIZE = 127; // Prime number large enough for most cases - private int elements; + private final ConcurrentHashMap table; public Environment() { this(SIZE); } public Environment(final int size) { - this.size = size; - table = new Vector[size]; + table = new ConcurrentHashMap<>(size); } - private Environment(final Vector[] table) { - size = table.length; + private Environment(final ConcurrentHashMap table) { this.table = table; } @Override public Object clone() { - final Vector[] copy = new Vector[size]; - - for (int i = 0; i < size; i++) { - if (table[i] != null) { - copy[i] = (Vector) table[i].clone(); // Copies references - - /* - * int len = table[i].size(); - * - * copy[i] = new Vector(len); try { for(int j=0; j < len; j++) copy[i].addElement(table[i].elementAt(j)); } - * catch (ArrayIndexOutOfBoundsException e) {} - */ - } - } - - return new Environment(copy); + return new Environment(new ConcurrentHashMap<>(table)); } /** * Delete an object if it does exist. */ public void delete(final String key) { - int hash; - Vector v; - - hash = hashCode(key); - v = table[hash]; - - if (v == null) { - return; - } - - try { - final int index = lookup(v, key); - - if (index >= 0) { - elements--; // Count - v.removeElementAt(index); - } - } catch (final ArrayIndexOutOfBoundsException e) { + if (key != null) { + table.remove(key); } } @@ -113,94 +61,24 @@ public void delete(final String key) { * Gets entry from hash table. */ public EnvEntry get(final String key) { - int hash; - Vector v; - EnvEntry entry = null; - - hash = hashCode(key); - v = table[hash]; - - if (v == null) { - return null; - } - - try { - final int index = lookup(v, key); - - if (index >= 0) { - entry = v.elementAt(index); - } - } catch (final ArrayIndexOutOfBoundsException e) { - } - - return entry; + return key != null ? table.get(key) : null; } public EnvEntry[] getEntries() { - final EnvEntry[] entries = new EnvEntry[elements]; - int k = 0; - Vector v; - - for (int i = 0; i < size; i++) { - if ((v = table[i]) != null) { - final int len = v.size(); - try { - for (int j = 0; j < len; j++) { - entries[k++] = v.elementAt(j); - } - } catch (final ArrayIndexOutOfBoundsException e) { - } - } - } - - return entries; - } - - private int hashCode(final String key) { - return Math.abs(key.hashCode()) % size; + return table.values().toArray(new EnvEntry[0]); } /** * Inserts macro into table or overwrite old contents if it was already stored. + * + * @param obj the entry to add. */ public void put(final EnvEntry obj) { - int hash; - Vector v; - final String key = obj.getHashKey(); - - hash = hashCode(key); - v = table[hash]; - - elements++; // Count - - if (v == null) { - table[hash] = v = new Vector<>(SLOTS); - } else { - try { - final int index = lookup(v, key); - - if (index >= 0) { - v.setElementAt(obj, index); // Overwrite - return; - } - } catch (final ArrayIndexOutOfBoundsException e) { - } - } - - // Not found in Vector -> add it - v.addElement(obj); + table.put(obj.getHashKey(), obj); } @Override public String toString() { - final StringBuilder buf = new StringBuilder(); - - for (int i = 0; i < size; i++) { - if (table[i] != null) { - buf.append(table[i] + "\n"); - } - } - - return buf.toString(); + return table.toString(); } } From 84f74957a61a8346b0331ec63ac8e006a6d0aede Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 11:15:35 -0400 Subject: [PATCH 070/114] Fix SpotBugs RV_ABSOLUTE_VALUE_OF_HASHCODE in Mini.Environment --- src/changes/changes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 353b07e500..f3a32463e2 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -69,6 +69,7 @@ The type attribute can be add,update,fix,remove. Fix SpotBugs URF_UNREAD_FIELD in ClassDumper. Fix SpotBugs DM_DEFAULT_ENCODING in JasminVisitor. Fix SpotBugs RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE in ASTFunAppl. + Fix SpotBugs RV_ABSOLUTE_VALUE_OF_HASHCODE in Mini.Environment. Add accessors to model and unit tests, Javadoc #183. From 644cfdbcfff5ebd6360fdc9209aa86507e8674ee Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 11:17:24 -0400 Subject: [PATCH 071/114] Fix SpotBugs DM_DEFAULT_ENCODING in Mini.MiniC --- src/changes/changes.xml | 1 + src/examples/Mini/MiniC.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f3a32463e2..f27b64cd34 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -70,6 +70,7 @@ The type attribute can be add,update,fix,remove. Fix SpotBugs DM_DEFAULT_ENCODING in JasminVisitor. Fix SpotBugs RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE in ASTFunAppl. Fix SpotBugs RV_ABSOLUTE_VALUE_OF_HASHCODE in Mini.Environment. + Fix SpotBugs DM_DEFAULT_ENCODING in Mini.MiniC. Add accessors to model and unit tests, Javadoc #183. diff --git a/src/examples/Mini/MiniC.java b/src/examples/Mini/MiniC.java index d9ee6a2725..eae9690992 100644 --- a/src/examples/Mini/MiniC.java +++ b/src/examples/Mini/MiniC.java @@ -20,6 +20,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import java.util.Objects; import java.util.Vector; @@ -155,7 +156,7 @@ public static void main(final String[] argv) { clazz.dump(baseName + JavaClass.EXTENSION); } else { System.out.println("Pass 5: Generating Java code..."); - try (final PrintWriter out = new PrintWriter(new FileOutputStream(baseName + ".java"))) { + try (final PrintWriter out = new PrintWriter(baseName + ".java", StandardCharsets.UTF_8.name())) { program.code(out, baseName); } From ed5a26c5dfb21b10bff8cbe8e631feaf7be2b314 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 11:18:10 -0400 Subject: [PATCH 072/114] Fix SpotBugs DM_DEFAULT_ENCODING in Mini.MiniC --- src/examples/Mini/MiniC.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/examples/Mini/MiniC.java b/src/examples/Mini/MiniC.java index eae9690992..685ca43917 100644 --- a/src/examples/Mini/MiniC.java +++ b/src/examples/Mini/MiniC.java @@ -18,7 +18,6 @@ import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.util.Objects; From b71d288305ff4daeea386e7d564a418d8c2744bc Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 11:24:33 -0400 Subject: [PATCH 073/114] Fix SpotBugs WMI_WRONG_MAP_ITERATOR in Package.go(String[]) [ERROR] Medium: Package.go(String[]) makes inefficient use of keySet iterator instead of entrySet iterator [Package] At Package.java:[line 221] WMI_WRONG_MAP_ITERATOR --- src/changes/changes.xml | 1 + src/examples/Package.java | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f27b64cd34..2b506a9cf4 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -71,6 +71,7 @@ The type attribute can be add,update,fix,remove. Fix SpotBugs RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE in ASTFunAppl. Fix SpotBugs RV_ABSOLUTE_VALUE_OF_HASHCODE in Mini.Environment. Fix SpotBugs DM_DEFAULT_ENCODING in Mini.MiniC. + Fix SpotBugs WMI_WRONG_MAP_ITERATOR in Package.go(String[]). Add accessors to model and unit tests, Javadoc #183. diff --git a/src/examples/Package.java b/src/examples/Package.java index 484b0072e0..051bb76199 100644 --- a/src/examples/Package.java +++ b/src/examples/Package.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.TreeMap; import java.util.jar.JarOutputStream; import java.util.zip.ZipEntry; @@ -217,9 +218,9 @@ void go(final String[] args) throws IOException { try (final JarOutputStream jarFile = new JarOutputStream(new FileOutputStream(defaultJar))) { jarFile.setLevel(5); // use compression int written = 0; - for (final String name : allClasses.keySet()) { // add entries for every class - final JavaClass claz = allClasses.get(name); - final ZipEntry zipEntry = new ZipEntry(name + JavaClass.EXTENSION); + for (final Entry entry : allClasses.entrySet()) { // add entries for every class + final JavaClass claz = allClasses.get(entry.getKey()); + final ZipEntry zipEntry = new ZipEntry(entry.getValue() + JavaClass.EXTENSION); final byte[] bytes = claz.getBytes(); final int length = bytes.length; jarFile.putNextEntry(zipEntry); From 9e9b3c9344f033982ee02c099e32f2f5cfa05247 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 11:31:55 -0400 Subject: [PATCH 074/114] Deprecate TransitiveHull.INGORED in favor of TransitiveHull.getIgnored() --- src/changes/changes.xml | 1 + src/conf/spotbugs-exclude-filter.xml | 28 +++++++++++++++++++++++++--- src/examples/TransitiveHull.java | 11 +++++++++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 2b506a9cf4..d0b76af917 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -72,6 +72,7 @@ The type attribute can be add,update,fix,remove. Fix SpotBugs RV_ABSOLUTE_VALUE_OF_HASHCODE in Mini.Environment. Fix SpotBugs DM_DEFAULT_ENCODING in Mini.MiniC. Fix SpotBugs WMI_WRONG_MAP_ITERATOR in Package.go(String[]). + Deprecate TransitiveHull.INGORED in favor of TransitiveHull.getIgnored(). Add accessors to model and unit tests, Javadoc #183. diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml index 0de6c6555e..f7c0cdf0c1 100644 --- a/src/conf/spotbugs-exclude-filter.xml +++ b/src/conf/spotbugs-exclude-filter.xml @@ -65,14 +65,19 @@ - - + + - + + + + + + + + + + @@ -189,4 +199,16 @@ + + + + + + + + + + + + diff --git a/src/examples/TransitiveHull.java b/src/examples/TransitiveHull.java index 719eb42921..9a34c1dbdd 100644 --- a/src/examples/TransitiveHull.java +++ b/src/examples/TransitiveHull.java @@ -35,6 +35,7 @@ import org.apache.bcel.generic.Type; import org.apache.bcel.util.ClassQueue; import org.apache.bcel.util.ClassSet; +import org.apache.commons.lang3.ArrayUtils; /** * Find all classes referenced by given start class and all classes referenced by those and so on. In other words: @@ -52,6 +53,12 @@ */ public class TransitiveHull extends org.apache.bcel.classfile.EmptyVisitor { + /** + * Should be private. + * + * @deprecated Use {@link #getIgnored()}. + */ + @Deprecated public static final String[] IGNORED = {"java[.].*", "javax[.].*", "sun[.].*", "sunw[.].*", "com[.]sun[.].*", "org[.]omg[.].*", "org[.]w3c[.].*", "org[.]xml[.].*", "net[.]jini[.].*"}; @@ -129,7 +136,7 @@ public String[] getClassNames() { } public String[] getIgnored() { - return ignored; + return ignored != null ? ignored.clone() : null; } /** @@ -138,7 +145,7 @@ public String[] getIgnored() { * @param v Value to assign to ignored. */ public void setIgnored(final String[] v) { - ignored = v; + ignored = ArrayUtils.clone(v); } /** From a87395efd3df37d48f52f67af3ed9d275053d42d Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 11:39:33 -0400 Subject: [PATCH 075/114] Bump org.apache.commons:commons-parent from 69 to 70 --- pom.xml | 2 +- src/changes/changes.xml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 95c352793c..897c5ec897 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.apache.commons commons-parent - 69 + 70 org.apache.bcel diff --git a/src/changes/changes.xml b/src/changes/changes.xml index d0b76af917..210e7aea13 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -78,7 +78,8 @@ The type attribute can be add,update,fix,remove. Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.0 #322. Bump tests from org.jetbrains.kotlin:kotlin-stdlib 1.9.23 to 2.0.0 #309, #318. - Bump tests from org.apache.commons:commons-collections4 4.4 to 4.5.0-M2. + Bump tests from org.apache.commons:commons-collections4 4.4 to 4.5.0-M2. + Bump org.apache.commons:commons-parent from 69 to 70.
From 0d04288f90c37b2e94a6e3c5d015ae9ee287a29a Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 14:08:17 -0400 Subject: [PATCH 076/114] Convert unit test to @ParameterizedTest --- .../ConstantPoolModuleAccessTestCase.java | 629 +++++++++--------- 1 file changed, 317 insertions(+), 312 deletions(-) diff --git a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java index 5202c4be1c..341c520054 100644 --- a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java +++ b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java @@ -16,343 +16,348 @@ */ package org.apache.bcel.classfile; -import org.apache.bcel.Const; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; -import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.apache.bcel.Const; +import org.apache.commons.lang3.stream.Streams; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests {@code module-info.class} files. */ -public class ConstantPoolModuleAccessTestCase { +public final class ConstantPoolModuleAccessTestCase { + + static Stream testJREModules() throws IOException { + return Streams.of(ConstantPoolModuleAccessTestCase.class.getClassLoader().getResources("module-info.class")); + } - @Test - public void testJREModules() throws Exception { - final Enumeration moduleURLs = getClass().getClassLoader().getResources("module-info.class"); - while (moduleURLs.hasMoreElements()) { - final URL url = moduleURLs.nextElement(); - try (InputStream inputStream = url.openStream()) { - final ClassParser classParser = new ClassParser(inputStream, "module-info.class"); - final JavaClass javaClass = classParser.parse(); - final ConstantPool constantPool = javaClass.getConstantPool(); - final EmptyVisitor visitor = new EmptyVisitor() { - @Override - public void visitModule(final Module obj) { - if (url.getPath().contains("/commons-")) { - assertEquals(4096, obj.getModuleFlags(), url.toString()); - } else { - assertEquals(0, obj.getModuleFlags(), url.toString()); + @ParameterizedTest + @MethodSource + public void testJREModules(final URL url) throws Exception { + try (InputStream inputStream = url.openStream()) { + final ClassParser classParser = new ClassParser(inputStream, "module-info.class"); + final JavaClass javaClass = classParser.parse(); + final ConstantPool constantPool = javaClass.getConstantPool(); + final EmptyVisitor visitor = new EmptyVisitor() { + @Override + public void visitModule(final Module obj) { + if (url.getPath().contains("/commons-")) { + assertEquals(4096, obj.getModuleFlags(), url.toString()); + } else { + assertEquals(0, obj.getModuleFlags(), url.toString()); + } + final String[] usedClassNames = obj.getUsedClassNames(constantPool, true); + if (url.getPath().contains("junit-jupiter-engine")) { + assertEquals(1, usedClassNames.length); + assertEquals("org.junit.jupiter.api.extension.Extension", usedClassNames[0]); + } else if (url.getPath().contains("junit-platform-launcher")) { + final List expected = new ArrayList<>(); + expected.add("org.junit.platform.engine.TestEngine"); + expected.add("org.junit.platform.launcher.LauncherDiscoveryListener"); + expected.add("org.junit.platform.launcher.LauncherInterceptor"); + expected.add("org.junit.platform.launcher.LauncherSessionListener"); + expected.add("org.junit.platform.launcher.PostDiscoveryFilter"); + expected.add("org.junit.platform.launcher.TestExecutionListener"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.rmi/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("java.rmi.server.RMIClassLoaderSpi"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.xml/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.xml.datatype.DatatypeFactory"); + expected.add("javax.xml.parsers.DocumentBuilderFactory"); + expected.add("javax.xml.parsers.SAXParserFactory"); + expected.add("javax.xml.stream.XMLEventFactory"); + expected.add("javax.xml.stream.XMLInputFactory"); + expected.add("javax.xml.stream.XMLOutputFactory"); + expected.add("javax.xml.transform.TransformerFactory"); + expected.add("javax.xml.validation.SchemaFactory"); + expected.add("javax.xml.xpath.XPathFactory"); + expected.add("org.xml.sax.XMLReader"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.datatransfer/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("sun.datatransfer.DesktopDatatransferService"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.desktop/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("java.awt.im.spi.InputMethodDescriptor"); + expected.add("javax.accessibility.AccessibilityProvider"); + expected.add("javax.imageio.spi.ImageInputStreamSpi"); + expected.add("javax.imageio.spi.ImageOutputStreamSpi"); + expected.add("javax.imageio.spi.ImageReaderSpi"); + expected.add("javax.imageio.spi.ImageTranscoderSpi"); + expected.add("javax.imageio.spi.ImageWriterSpi"); + expected.add("javax.print.PrintServiceLookup"); + expected.add("javax.print.StreamPrintServiceFactory"); + expected.add("javax.sound.midi.spi.MidiDeviceProvider"); + expected.add("javax.sound.midi.spi.MidiFileReader"); + expected.add("javax.sound.midi.spi.MidiFileWriter"); + expected.add("javax.sound.midi.spi.SoundbankReader"); + expected.add("javax.sound.sampled.spi.AudioFileReader"); + expected.add("javax.sound.sampled.spi.AudioFileWriter"); + expected.add("javax.sound.sampled.spi.FormatConversionProvider"); + expected.add("javax.sound.sampled.spi.MixerProvider"); + expected.add("sun.swing.InteropProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.naming/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.naming.ldap.StartTlsResponse"); + expected.add("javax.naming.spi.InitialContextFactory"); + if (javaClass.getMajor() > Const.MAJOR_11) { + expected.add("javax.naming.ldap.spi.LdapDnsProvider"); + } + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.prefs/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("java.util.prefs.PreferencesFactory"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.base/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("java.lang.System$LoggerFinder"); + expected.add("java.net.ContentHandlerFactory"); + if (javaClass.getMajor() > Const.MAJOR_17) { + expected.add("java.net.spi.InetAddressResolverProvider"); + } + expected.add("java.net.spi.URLStreamHandlerProvider"); + expected.add("java.nio.channels.spi.AsynchronousChannelProvider"); + expected.add("java.nio.channels.spi.SelectorProvider"); + expected.add("java.nio.charset.spi.CharsetProvider"); + expected.add("java.nio.file.spi.FileSystemProvider"); + expected.add("java.nio.file.spi.FileTypeDetector"); + expected.add("java.security.Provider"); + expected.add("java.text.spi.BreakIteratorProvider"); + expected.add("java.text.spi.CollatorProvider"); + expected.add("java.text.spi.DateFormatProvider"); + expected.add("java.text.spi.DateFormatSymbolsProvider"); + expected.add("java.text.spi.DecimalFormatSymbolsProvider"); + expected.add("java.text.spi.NumberFormatProvider"); + expected.add("java.time.chrono.AbstractChronology"); + expected.add("java.time.chrono.Chronology"); + expected.add("java.time.zone.ZoneRulesProvider"); + if (javaClass.getMajor() > Const.MAJOR_11) { + expected.add("java.util.random.RandomGenerator"); } - final String[] usedClassNames = obj.getUsedClassNames(constantPool, true); - if (url.getPath().contains("junit-jupiter-engine")) { - assertEquals(1, usedClassNames.length); - assertEquals("org.junit.jupiter.api.extension.Extension", usedClassNames[0]); - } else if (url.getPath().contains("junit-platform-launcher")) { - final List expected = new ArrayList<>(); - expected.add("org.junit.platform.engine.TestEngine"); - expected.add("org.junit.platform.launcher.LauncherDiscoveryListener"); - expected.add("org.junit.platform.launcher.LauncherInterceptor"); - expected.add("org.junit.platform.launcher.LauncherSessionListener"); - expected.add("org.junit.platform.launcher.PostDiscoveryFilter"); - expected.add("org.junit.platform.launcher.TestExecutionListener"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.rmi/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("java.rmi.server.RMIClassLoaderSpi"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.xml/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("javax.xml.datatype.DatatypeFactory"); - expected.add("javax.xml.parsers.DocumentBuilderFactory"); - expected.add("javax.xml.parsers.SAXParserFactory"); - expected.add("javax.xml.stream.XMLEventFactory"); - expected.add("javax.xml.stream.XMLInputFactory"); - expected.add("javax.xml.stream.XMLOutputFactory"); - expected.add("javax.xml.transform.TransformerFactory"); - expected.add("javax.xml.validation.SchemaFactory"); - expected.add("javax.xml.xpath.XPathFactory"); - expected.add("org.xml.sax.XMLReader"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.datatransfer/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("sun.datatransfer.DesktopDatatransferService"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.desktop/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("java.awt.im.spi.InputMethodDescriptor"); - expected.add("javax.accessibility.AccessibilityProvider"); - expected.add("javax.imageio.spi.ImageInputStreamSpi"); - expected.add("javax.imageio.spi.ImageOutputStreamSpi"); - expected.add("javax.imageio.spi.ImageReaderSpi"); - expected.add("javax.imageio.spi.ImageTranscoderSpi"); - expected.add("javax.imageio.spi.ImageWriterSpi"); - expected.add("javax.print.PrintServiceLookup"); - expected.add("javax.print.StreamPrintServiceFactory"); - expected.add("javax.sound.midi.spi.MidiDeviceProvider"); - expected.add("javax.sound.midi.spi.MidiFileReader"); - expected.add("javax.sound.midi.spi.MidiFileWriter"); - expected.add("javax.sound.midi.spi.SoundbankReader"); - expected.add("javax.sound.sampled.spi.AudioFileReader"); - expected.add("javax.sound.sampled.spi.AudioFileWriter"); - expected.add("javax.sound.sampled.spi.FormatConversionProvider"); - expected.add("javax.sound.sampled.spi.MixerProvider"); - expected.add("sun.swing.InteropProvider"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.naming/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("javax.naming.ldap.StartTlsResponse"); - expected.add("javax.naming.spi.InitialContextFactory"); - if (javaClass.getMajor() > Const.MAJOR_11) { - expected.add("javax.naming.ldap.spi.LdapDnsProvider"); - } - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.prefs/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("java.util.prefs.PreferencesFactory"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.base/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("java.lang.System$LoggerFinder"); - expected.add("java.net.ContentHandlerFactory"); - if (javaClass.getMajor() > Const.MAJOR_17) { - expected.add("java.net.spi.InetAddressResolverProvider"); - } - expected.add("java.net.spi.URLStreamHandlerProvider"); - expected.add("java.nio.channels.spi.AsynchronousChannelProvider"); - expected.add("java.nio.channels.spi.SelectorProvider"); - expected.add("java.nio.charset.spi.CharsetProvider"); - expected.add("java.nio.file.spi.FileSystemProvider"); - expected.add("java.nio.file.spi.FileTypeDetector"); - expected.add("java.security.Provider"); - expected.add("java.text.spi.BreakIteratorProvider"); - expected.add("java.text.spi.CollatorProvider"); - expected.add("java.text.spi.DateFormatProvider"); - expected.add("java.text.spi.DateFormatSymbolsProvider"); - expected.add("java.text.spi.DecimalFormatSymbolsProvider"); - expected.add("java.text.spi.NumberFormatProvider"); - expected.add("java.time.chrono.AbstractChronology"); - expected.add("java.time.chrono.Chronology"); - expected.add("java.time.zone.ZoneRulesProvider"); - if (javaClass.getMajor() > Const.MAJOR_11) { - expected.add("java.util.random.RandomGenerator"); - } - expected.add("java.util.spi.CalendarDataProvider"); - expected.add("java.util.spi.CalendarNameProvider"); - expected.add("java.util.spi.CurrencyNameProvider"); - expected.add("java.util.spi.LocaleNameProvider"); - expected.add("java.util.spi.ResourceBundleControlProvider"); - expected.add("java.util.spi.ResourceBundleProvider"); - expected.add("java.util.spi.TimeZoneNameProvider"); - expected.add("java.util.spi.ToolProvider"); - expected.add("javax.security.auth.spi.LoginModule"); - if (javaClass.getMajor() > Const.MAJOR_17) { - expected.add("jdk.internal.io.JdkConsoleProvider"); - } - expected.add("jdk.internal.logger.DefaultLoggerFinder"); - expected.add("sun.text.spi.JavaTimeDateTimePatternProvider"); - expected.add("sun.util.locale.provider.LocaleDataMetaInfo"); - expected.add("sun.util.resources.LocaleData$CommonResourceBundleProvider"); - expected.add("sun.util.resources.LocaleData$SupplementaryResourceBundleProvider"); - expected.add("sun.util.spi.CalendarProvider"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.management.agent/module-info.class") && javaClass.getMajor() < Const.MAJOR_21) { - final List expected = new ArrayList<>(); - expected.add("jdk.internal.agent.spi.AgentProvider"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.management/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("javax.management.remote.JMXConnectorProvider"); - expected.add("javax.management.remote.JMXConnectorServerProvider"); - expected.add("sun.management.spi.PlatformMBeanProvider"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.sql/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("java.sql.Driver"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.httpserver/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("com.sun.net.httpserver.spi.HttpServerProvider"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.sql.rowset/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("javax.sql.rowset.RowSetFactory"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.compiler/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("javax.tools.DocumentationTool"); - expected.add("javax.tools.JavaCompiler"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.scripting/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("javax.script.ScriptEngineFactory"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.dynalink/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("jdk.dynalink.linker.GuardingDynamicLinkerExporter"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jdi/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("com.sun.jdi.connect.Connector"); - expected.add("com.sun.jdi.connect.spi.TransportService"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.compiler/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("javax.annotation.processing.Processor"); - expected.add("com.sun.source.util.Plugin"); - if (javaClass.getMajor() > Const.MAJOR_11) { - expected.add("com.sun.tools.doclint.DocLint"); - } - expected.add("com.sun.tools.javac.platform.PlatformProvider"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jconsole/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("com.sun.tools.jconsole.JConsolePlugin"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.attach/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("com.sun.tools.attach.spi.AttachProvider"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jshell/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("jdk.jshell.spi.ExecutionControlProvider"); - expected.add("jdk.internal.editor.spi.BuildInEditorProvider"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.internal.le/module-info.class")) { - final List expected = new ArrayList<>(); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jlink/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("jdk.tools.jlink.plugin.Plugin"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.internal.jvmstat/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("sun.jvmstat.monitor.MonitoredHostService"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jpackage/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("jdk.jpackage.internal.Bundler"); - expected.add("jdk.jpackage.internal.Bundlers"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.naming.ldap/module-info.class")) { - final List expected = new ArrayList<>(); - expected.add("com.sun.jndi.ldap.spi.LdapDnsProvider"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jsobject/module-info.class") && javaClass.getMajor() == Const.MAJOR_11) { - final List expected = new ArrayList<>(); - expected.add("jdk.internal.netscape.javascript.spi.JSObjectProvider"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/org/assertj/assertj-core/")) { - final List expected = new ArrayList<>(); - expected.add("org.assertj.core.configuration.Configuration"); - expected.add("org.assertj.core.presentation.Representation"); - assertEquals(expected, Arrays.asList(usedClassNames)); - } else { - assertEquals(0, usedClassNames.length, "Found " + Arrays.toString(usedClassNames) + " in " + url.getPath()); + expected.add("java.util.spi.CalendarDataProvider"); + expected.add("java.util.spi.CalendarNameProvider"); + expected.add("java.util.spi.CurrencyNameProvider"); + expected.add("java.util.spi.LocaleNameProvider"); + expected.add("java.util.spi.ResourceBundleControlProvider"); + expected.add("java.util.spi.ResourceBundleProvider"); + expected.add("java.util.spi.TimeZoneNameProvider"); + expected.add("java.util.spi.ToolProvider"); + expected.add("javax.security.auth.spi.LoginModule"); + if (javaClass.getMajor() > Const.MAJOR_17) { + expected.add("jdk.internal.io.JdkConsoleProvider"); } - super.visitModule(obj); + expected.add("jdk.internal.logger.DefaultLoggerFinder"); + expected.add("sun.text.spi.JavaTimeDateTimePatternProvider"); + expected.add("sun.util.locale.provider.LocaleDataMetaInfo"); + expected.add("sun.util.resources.LocaleData$CommonResourceBundleProvider"); + expected.add("sun.util.resources.LocaleData$SupplementaryResourceBundleProvider"); + expected.add("sun.util.spi.CalendarProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.management.agent/module-info.class") && javaClass.getMajor() < Const.MAJOR_21) { + final List expected = new ArrayList<>(); + expected.add("jdk.internal.agent.spi.AgentProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.management/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.management.remote.JMXConnectorProvider"); + expected.add("javax.management.remote.JMXConnectorServerProvider"); + expected.add("sun.management.spi.PlatformMBeanProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.sql/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("java.sql.Driver"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.httpserver/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("com.sun.net.httpserver.spi.HttpServerProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.sql.rowset/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.sql.rowset.RowSetFactory"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.compiler/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.tools.DocumentationTool"); + expected.add("javax.tools.JavaCompiler"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/java.scripting/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.script.ScriptEngineFactory"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.dynalink/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("jdk.dynalink.linker.GuardingDynamicLinkerExporter"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jdi/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("com.sun.jdi.connect.Connector"); + expected.add("com.sun.jdi.connect.spi.TransportService"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.compiler/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("javax.annotation.processing.Processor"); + expected.add("com.sun.source.util.Plugin"); + if (javaClass.getMajor() > Const.MAJOR_11) { + expected.add("com.sun.tools.doclint.DocLint"); + } + expected.add("com.sun.tools.javac.platform.PlatformProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jconsole/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("com.sun.tools.jconsole.JConsolePlugin"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.attach/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("com.sun.tools.attach.spi.AttachProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jshell/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("jdk.jshell.spi.ExecutionControlProvider"); + expected.add("jdk.internal.editor.spi.BuildInEditorProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.internal.le/module-info.class")) { + final List expected = new ArrayList<>(); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jlink/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("jdk.tools.jlink.plugin.Plugin"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.internal.jvmstat/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("sun.jvmstat.monitor.MonitoredHostService"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jpackage/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("jdk.jpackage.internal.Bundler"); + expected.add("jdk.jpackage.internal.Bundlers"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.naming.ldap/module-info.class")) { + final List expected = new ArrayList<>(); + expected.add("com.sun.jndi.ldap.spi.LdapDnsProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/jdk.jsobject/module-info.class") && javaClass.getMajor() == Const.MAJOR_11) { + final List expected = new ArrayList<>(); + expected.add("jdk.internal.netscape.javascript.spi.JSObjectProvider"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (url.getPath().contains("/org/assertj/assertj-core/")) { + final List expected = new ArrayList<>(); + expected.add("org.assertj.core.configuration.Configuration"); + expected.add("org.assertj.core.presentation.Representation"); + assertEquals(expected, Arrays.asList(usedClassNames)); + } else { + assertEquals(0, usedClassNames.length, "Found " + Arrays.toString(usedClassNames) + " in " + url.getPath()); } + super.visitModule(obj); + } - @Override - public void visitModuleExports(final ModuleExports obj) { - assertEquals(0, obj.getExportsFlags(), url.toString()); - final String packageName = obj.getPackageName(constantPool); - final String[] toModuleNames = obj.getToModuleNames(constantPool); - if (url.getPath().contains("junit-platform-commons")) { - final List expected = new ArrayList<>(); - expected.add("org.junit.jupiter.api"); - expected.add("org.junit.jupiter.engine"); - expected.add("org.junit.jupiter.migrationsupport"); - expected.add("org.junit.jupiter.params"); - expected.add("org.junit.platform.console"); - expected.add("org.junit.platform.engine"); - expected.add("org.junit.platform.launcher"); - expected.add("org.junit.platform.reporting"); - expected.add("org.junit.platform.runner"); - expected.add("org.junit.platform.suite.api"); - switch (packageName) { - case "org.junit.platform.commons.util": - expected.add("org.junit.platform.suite.commons"); - expected.add("org.junit.platform.suite.engine"); - expected.add("org.junit.platform.testkit"); - expected.add("org.junit.vintage.engine"); - assertEquals(expected, Arrays.asList(toModuleNames)); - break; - case "org.junit.platform.commons.logging": - expected.add("org.junit.platform.suite.engine"); - expected.add("org.junit.platform.testkit"); - expected.add("org.junit.vintage.engine"); - assertEquals(expected, Arrays.asList(toModuleNames)); - break; - default: - assertEquals(0, toModuleNames.length); - break; - } + @Override + public void visitModuleExports(final ModuleExports obj) { + assertEquals(0, obj.getExportsFlags(), url.toString()); + final String packageName = obj.getPackageName(constantPool); + final String[] toModuleNames = obj.getToModuleNames(constantPool); + if (url.getPath().contains("junit-platform-commons")) { + final List expected = new ArrayList<>(); + expected.add("org.junit.jupiter.api"); + expected.add("org.junit.jupiter.engine"); + expected.add("org.junit.jupiter.migrationsupport"); + expected.add("org.junit.jupiter.params"); + expected.add("org.junit.platform.console"); + expected.add("org.junit.platform.engine"); + expected.add("org.junit.platform.launcher"); + expected.add("org.junit.platform.reporting"); + expected.add("org.junit.platform.runner"); + expected.add("org.junit.platform.suite.api"); + switch (packageName) { + case "org.junit.platform.commons.util": + expected.add("org.junit.platform.suite.commons"); + expected.add("org.junit.platform.suite.engine"); + expected.add("org.junit.platform.testkit"); + expected.add("org.junit.vintage.engine"); + assertEquals(expected, Arrays.asList(toModuleNames)); + break; + case "org.junit.platform.commons.logging": + expected.add("org.junit.platform.suite.engine"); + expected.add("org.junit.platform.testkit"); + expected.add("org.junit.vintage.engine"); + assertEquals(expected, Arrays.asList(toModuleNames)); + break; + default: + assertEquals(0, toModuleNames.length); + break; } - super.visitModuleExports(obj); } + super.visitModuleExports(obj); + } - @Override - public void visitModuleProvides(final ModuleProvides obj) { - final String interfaceName = obj.getInterfaceName(constantPool); - final String[] implementationClassNames = obj.getImplementationClassNames(constantPool, true); - if (url.getPath().contains("junit-jupiter-engine")) { - assertEquals("org.junit.platform.engine.TestEngine", interfaceName); - assertEquals(1, implementationClassNames.length); - assertEquals("org.junit.jupiter.engine.JupiterTestEngine", implementationClassNames[0]); - } else if (url.getPath().contains("junit-platform-launcher")) { - assertEquals("org.junit.platform.launcher.TestExecutionListener", interfaceName); - assertEquals(1, implementationClassNames.length); - assertEquals("org.junit.platform.launcher.listeners.UniqueIdTrackingListener", implementationClassNames[0]); - } - super.visitModuleProvides(obj); + @Override + public void visitModuleOpens(final ModuleOpens obj) { + assertEquals(0, obj.getOpensFlags(), url.toString()); + final String packageName = obj.getPackageName(constantPool); + final String[] toModuleNames = obj.getToModuleNames(constantPool); + if (url.getPath().contains("junit-jupiter-engine")) { + assertEquals("org.junit.jupiter.engine.extension", packageName); + assertEquals(1, toModuleNames.length); + assertEquals("org.junit.platform.commons", toModuleNames[0]); } + if (url.getPath().contains("junit-jupiter-api")) { + assertEquals("org.junit.jupiter.api.condition", packageName); + assertEquals(1, toModuleNames.length); + assertEquals("org.junit.platform.commons", toModuleNames[0]); + } + super.visitModuleOpens(obj); + } - @Override - public void visitModuleOpens(final ModuleOpens obj) { - assertEquals(0, obj.getOpensFlags(), url.toString()); - final String packageName = obj.getPackageName(constantPool); - final String[] toModuleNames = obj.getToModuleNames(constantPool); - if (url.getPath().contains("junit-jupiter-engine")) { - assertEquals("org.junit.jupiter.engine.extension", packageName); - assertEquals(1, toModuleNames.length); - assertEquals("org.junit.platform.commons", toModuleNames[0]); - } - if (url.getPath().contains("junit-jupiter-api")) { - assertEquals("org.junit.jupiter.api.condition", packageName); - assertEquals(1, toModuleNames.length); - assertEquals("org.junit.platform.commons", toModuleNames[0]); - } - super.visitModuleOpens(obj); + @Override + public void visitModuleProvides(final ModuleProvides obj) { + final String interfaceName = obj.getInterfaceName(constantPool); + final String[] implementationClassNames = obj.getImplementationClassNames(constantPool, true); + if (url.getPath().contains("junit-jupiter-engine")) { + assertEquals("org.junit.platform.engine.TestEngine", interfaceName); + assertEquals(1, implementationClassNames.length); + assertEquals("org.junit.jupiter.engine.JupiterTestEngine", implementationClassNames[0]); + } else if (url.getPath().contains("junit-platform-launcher")) { + assertEquals("org.junit.platform.launcher.TestExecutionListener", interfaceName); + assertEquals(1, implementationClassNames.length); + assertEquals("org.junit.platform.launcher.listeners.UniqueIdTrackingListener", implementationClassNames[0]); } + super.visitModuleProvides(obj); + } - @Override - public void visitModuleRequires(final ModuleRequires obj) { - if (url.getPath().contains("junit-jupiter-engine")) { - final String moduleName = obj.getModuleName(constantPool); - final Map expected = new HashMap<>(); - expected.put("java.base", 32768); - expected.put("org.apiguardian.api", 64); - expected.put("org.junit.jupiter.api", 0); - expected.put("org.junit.platform.commons", 0); - expected.put("org.junit.platform.engine", 0); - expected.put("org.opentest4j", 0); - assertTrue(expected.containsKey(moduleName)); - assertEquals(expected.get(moduleName), obj.getRequiresFlags(), moduleName); - } - super.visitModuleRequires(obj); + @Override + public void visitModuleRequires(final ModuleRequires obj) { + if (url.getPath().contains("junit-jupiter-engine")) { + final String moduleName = obj.getModuleName(constantPool); + final Map expected = new HashMap<>(); + expected.put("java.base", 32768); + expected.put("org.apiguardian.api", 64); + expected.put("org.junit.jupiter.api", 0); + expected.put("org.junit.platform.commons", 0); + expected.put("org.junit.platform.engine", 0); + expected.put("org.opentest4j", 0); + assertTrue(expected.containsKey(moduleName)); + assertEquals(expected.get(moduleName), obj.getRequiresFlags(), moduleName); } - }; - javaClass.accept(new DescendingVisitor(javaClass, visitor)); - } + super.visitModuleRequires(obj); + } + }; + javaClass.accept(new DescendingVisitor(javaClass, visitor)); } } } From 7e9f30a62585b929949619842373eddb6e543c43 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 14:16:37 -0400 Subject: [PATCH 077/114] Refactor common call --- .../ConstantPoolModuleAccessTestCase.java | 73 ++++++++++--------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java index 341c520054..b0ba83aa68 100644 --- a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java +++ b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java @@ -53,16 +53,17 @@ public void testJREModules(final URL url) throws Exception { final EmptyVisitor visitor = new EmptyVisitor() { @Override public void visitModule(final Module obj) { - if (url.getPath().contains("/commons-")) { + final String urlPath = url.getPath(); + if (urlPath.contains("/commons-")) { assertEquals(4096, obj.getModuleFlags(), url.toString()); } else { assertEquals(0, obj.getModuleFlags(), url.toString()); } final String[] usedClassNames = obj.getUsedClassNames(constantPool, true); - if (url.getPath().contains("junit-jupiter-engine")) { + if (urlPath.contains("junit-jupiter-engine")) { assertEquals(1, usedClassNames.length); assertEquals("org.junit.jupiter.api.extension.Extension", usedClassNames[0]); - } else if (url.getPath().contains("junit-platform-launcher")) { + } else if (urlPath.contains("junit-platform-launcher")) { final List expected = new ArrayList<>(); expected.add("org.junit.platform.engine.TestEngine"); expected.add("org.junit.platform.launcher.LauncherDiscoveryListener"); @@ -71,11 +72,11 @@ public void visitModule(final Module obj) { expected.add("org.junit.platform.launcher.PostDiscoveryFilter"); expected.add("org.junit.platform.launcher.TestExecutionListener"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.rmi/module-info.class")) { + } else if (urlPath.contains("/java.rmi/module-info.class")) { final List expected = new ArrayList<>(); expected.add("java.rmi.server.RMIClassLoaderSpi"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.xml/module-info.class")) { + } else if (urlPath.contains("/java.xml/module-info.class")) { final List expected = new ArrayList<>(); expected.add("javax.xml.datatype.DatatypeFactory"); expected.add("javax.xml.parsers.DocumentBuilderFactory"); @@ -88,11 +89,11 @@ public void visitModule(final Module obj) { expected.add("javax.xml.xpath.XPathFactory"); expected.add("org.xml.sax.XMLReader"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.datatransfer/module-info.class")) { + } else if (urlPath.contains("/java.datatransfer/module-info.class")) { final List expected = new ArrayList<>(); expected.add("sun.datatransfer.DesktopDatatransferService"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.desktop/module-info.class")) { + } else if (urlPath.contains("/java.desktop/module-info.class")) { final List expected = new ArrayList<>(); expected.add("java.awt.im.spi.InputMethodDescriptor"); expected.add("javax.accessibility.AccessibilityProvider"); @@ -113,7 +114,7 @@ public void visitModule(final Module obj) { expected.add("javax.sound.sampled.spi.MixerProvider"); expected.add("sun.swing.InteropProvider"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.naming/module-info.class")) { + } else if (urlPath.contains("/java.naming/module-info.class")) { final List expected = new ArrayList<>(); expected.add("javax.naming.ldap.StartTlsResponse"); expected.add("javax.naming.spi.InitialContextFactory"); @@ -121,11 +122,11 @@ public void visitModule(final Module obj) { expected.add("javax.naming.ldap.spi.LdapDnsProvider"); } assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.prefs/module-info.class")) { + } else if (urlPath.contains("/java.prefs/module-info.class")) { final List expected = new ArrayList<>(); expected.add("java.util.prefs.PreferencesFactory"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.base/module-info.class")) { + } else if (urlPath.contains("/java.base/module-info.class")) { final List expected = new ArrayList<>(); expected.add("java.lang.System$LoggerFinder"); expected.add("java.net.ContentHandlerFactory"); @@ -170,47 +171,47 @@ public void visitModule(final Module obj) { expected.add("sun.util.resources.LocaleData$SupplementaryResourceBundleProvider"); expected.add("sun.util.spi.CalendarProvider"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.management.agent/module-info.class") && javaClass.getMajor() < Const.MAJOR_21) { + } else if (urlPath.contains("/jdk.management.agent/module-info.class") && javaClass.getMajor() < Const.MAJOR_21) { final List expected = new ArrayList<>(); expected.add("jdk.internal.agent.spi.AgentProvider"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.management/module-info.class")) { + } else if (urlPath.contains("/java.management/module-info.class")) { final List expected = new ArrayList<>(); expected.add("javax.management.remote.JMXConnectorProvider"); expected.add("javax.management.remote.JMXConnectorServerProvider"); expected.add("sun.management.spi.PlatformMBeanProvider"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.sql/module-info.class")) { + } else if (urlPath.contains("/java.sql/module-info.class")) { final List expected = new ArrayList<>(); expected.add("java.sql.Driver"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.httpserver/module-info.class")) { + } else if (urlPath.contains("/jdk.httpserver/module-info.class")) { final List expected = new ArrayList<>(); expected.add("com.sun.net.httpserver.spi.HttpServerProvider"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.sql.rowset/module-info.class")) { + } else if (urlPath.contains("/java.sql.rowset/module-info.class")) { final List expected = new ArrayList<>(); expected.add("javax.sql.rowset.RowSetFactory"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.compiler/module-info.class")) { + } else if (urlPath.contains("/java.compiler/module-info.class")) { final List expected = new ArrayList<>(); expected.add("javax.tools.DocumentationTool"); expected.add("javax.tools.JavaCompiler"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/java.scripting/module-info.class")) { + } else if (urlPath.contains("/java.scripting/module-info.class")) { final List expected = new ArrayList<>(); expected.add("javax.script.ScriptEngineFactory"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.dynalink/module-info.class")) { + } else if (urlPath.contains("/jdk.dynalink/module-info.class")) { final List expected = new ArrayList<>(); expected.add("jdk.dynalink.linker.GuardingDynamicLinkerExporter"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jdi/module-info.class")) { + } else if (urlPath.contains("/jdk.jdi/module-info.class")) { final List expected = new ArrayList<>(); expected.add("com.sun.jdi.connect.Connector"); expected.add("com.sun.jdi.connect.spi.TransportService"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.compiler/module-info.class")) { + } else if (urlPath.contains("/jdk.compiler/module-info.class")) { final List expected = new ArrayList<>(); expected.add("javax.annotation.processing.Processor"); expected.add("com.sun.source.util.Plugin"); @@ -219,50 +220,50 @@ public void visitModule(final Module obj) { } expected.add("com.sun.tools.javac.platform.PlatformProvider"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jconsole/module-info.class")) { + } else if (urlPath.contains("/jdk.jconsole/module-info.class")) { final List expected = new ArrayList<>(); expected.add("com.sun.tools.jconsole.JConsolePlugin"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.attach/module-info.class")) { + } else if (urlPath.contains("/jdk.attach/module-info.class")) { final List expected = new ArrayList<>(); expected.add("com.sun.tools.attach.spi.AttachProvider"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jshell/module-info.class")) { + } else if (urlPath.contains("/jdk.jshell/module-info.class")) { final List expected = new ArrayList<>(); expected.add("jdk.jshell.spi.ExecutionControlProvider"); expected.add("jdk.internal.editor.spi.BuildInEditorProvider"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.internal.le/module-info.class")) { + } else if (urlPath.contains("/jdk.internal.le/module-info.class")) { final List expected = new ArrayList<>(); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jlink/module-info.class")) { + } else if (urlPath.contains("/jdk.jlink/module-info.class")) { final List expected = new ArrayList<>(); expected.add("jdk.tools.jlink.plugin.Plugin"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.internal.jvmstat/module-info.class")) { + } else if (urlPath.contains("/jdk.internal.jvmstat/module-info.class")) { final List expected = new ArrayList<>(); expected.add("sun.jvmstat.monitor.MonitoredHostService"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jpackage/module-info.class")) { + } else if (urlPath.contains("/jdk.jpackage/module-info.class")) { final List expected = new ArrayList<>(); expected.add("jdk.jpackage.internal.Bundler"); expected.add("jdk.jpackage.internal.Bundlers"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.naming.ldap/module-info.class")) { + } else if (urlPath.contains("/jdk.naming.ldap/module-info.class")) { final List expected = new ArrayList<>(); expected.add("com.sun.jndi.ldap.spi.LdapDnsProvider"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/jdk.jsobject/module-info.class") && javaClass.getMajor() == Const.MAJOR_11) { + } else if (urlPath.contains("/jdk.jsobject/module-info.class") && javaClass.getMajor() == Const.MAJOR_11) { final List expected = new ArrayList<>(); expected.add("jdk.internal.netscape.javascript.spi.JSObjectProvider"); assertEquals(expected, Arrays.asList(usedClassNames)); - } else if (url.getPath().contains("/org/assertj/assertj-core/")) { + } else if (urlPath.contains("/org/assertj/assertj-core/")) { final List expected = new ArrayList<>(); expected.add("org.assertj.core.configuration.Configuration"); expected.add("org.assertj.core.presentation.Representation"); assertEquals(expected, Arrays.asList(usedClassNames)); } else { - assertEquals(0, usedClassNames.length, "Found " + Arrays.toString(usedClassNames) + " in " + url.getPath()); + assertEquals(0, usedClassNames.length, "Found " + Arrays.toString(usedClassNames) + " in " + urlPath); } super.visitModule(obj); } @@ -311,12 +312,13 @@ public void visitModuleOpens(final ModuleOpens obj) { assertEquals(0, obj.getOpensFlags(), url.toString()); final String packageName = obj.getPackageName(constantPool); final String[] toModuleNames = obj.getToModuleNames(constantPool); - if (url.getPath().contains("junit-jupiter-engine")) { + final String urlPath = url.getPath(); + if (urlPath.contains("junit-jupiter-engine")) { assertEquals("org.junit.jupiter.engine.extension", packageName); assertEquals(1, toModuleNames.length); assertEquals("org.junit.platform.commons", toModuleNames[0]); } - if (url.getPath().contains("junit-jupiter-api")) { + if (urlPath.contains("junit-jupiter-api")) { assertEquals("org.junit.jupiter.api.condition", packageName); assertEquals(1, toModuleNames.length); assertEquals("org.junit.platform.commons", toModuleNames[0]); @@ -328,11 +330,12 @@ public void visitModuleOpens(final ModuleOpens obj) { public void visitModuleProvides(final ModuleProvides obj) { final String interfaceName = obj.getInterfaceName(constantPool); final String[] implementationClassNames = obj.getImplementationClassNames(constantPool, true); - if (url.getPath().contains("junit-jupiter-engine")) { + final String urlPath = url.getPath(); + if (urlPath.contains("junit-jupiter-engine")) { assertEquals("org.junit.platform.engine.TestEngine", interfaceName); assertEquals(1, implementationClassNames.length); assertEquals("org.junit.jupiter.engine.JupiterTestEngine", implementationClassNames[0]); - } else if (url.getPath().contains("junit-platform-launcher")) { + } else if (urlPath.contains("junit-platform-launcher")) { assertEquals("org.junit.platform.launcher.TestExecutionListener", interfaceName); assertEquals(1, implementationClassNames.length); assertEquals("org.junit.platform.launcher.listeners.UniqueIdTrackingListener", implementationClassNames[0]); From ea940944ee122cdce538002c5b96bbcda6f914df Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 14:18:32 -0400 Subject: [PATCH 078/114] Use if-else --- .../bcel/classfile/ConstantPoolModuleAccessTestCase.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java index b0ba83aa68..d43848dc35 100644 --- a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java +++ b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java @@ -317,8 +317,7 @@ public void visitModuleOpens(final ModuleOpens obj) { assertEquals("org.junit.jupiter.engine.extension", packageName); assertEquals(1, toModuleNames.length); assertEquals("org.junit.platform.commons", toModuleNames[0]); - } - if (urlPath.contains("junit-jupiter-api")) { + } else if (urlPath.contains("junit-jupiter-api")) { assertEquals("org.junit.jupiter.api.condition", packageName); assertEquals(1, toModuleNames.length); assertEquals("org.junit.platform.commons", toModuleNames[0]); From 6719429ab71b997ccd37eae2299d0ee13d849961 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 14:30:11 -0400 Subject: [PATCH 079/114] Bump org.apache.commons:commons-parent from 70 to 71 --- pom.xml | 2 +- src/changes/changes.xml | 2 +- .../bcel/classfile/ConstantPoolModuleAccessTestCase.java | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 897c5ec897..1e3ec8f0fe 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.apache.commons commons-parent - 70 + 71 org.apache.bcel diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 210e7aea13..b54aaafaea 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -79,7 +79,7 @@ The type attribute can be add,update,fix,remove. Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.0 #322. Bump tests from org.jetbrains.kotlin:kotlin-stdlib 1.9.23 to 2.0.0 #309, #318. Bump tests from org.apache.commons:commons-collections4 4.4 to 4.5.0-M2. - Bump org.apache.commons:commons-parent from 69 to 70. + Bump org.apache.commons:commons-parent from 69 to 71. diff --git a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java index d43848dc35..2c4eb29045 100644 --- a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java +++ b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleAccessTestCase.java @@ -72,6 +72,10 @@ public void visitModule(final Module obj) { expected.add("org.junit.platform.launcher.PostDiscoveryFilter"); expected.add("org.junit.platform.launcher.TestExecutionListener"); assertEquals(expected, Arrays.asList(usedClassNames)); + } else if (urlPath.contains("junit-platform-engine")) { + final List expected = new ArrayList<>(); + expected.add("org.junit.platform.engine.discovery.DiscoverySelectorIdentifierParser"); + assertEquals(expected, Arrays.asList(usedClassNames)); } else if (urlPath.contains("/java.rmi/module-info.class")) { final List expected = new ArrayList<>(); expected.add("java.rmi.server.RMIClassLoaderSpi"); From 4e10d23275f7dff337433de5d4d7910c0337a606 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 14:57:07 -0400 Subject: [PATCH 080/114] Sort members --- src/examples/Mini/Environment.java | 8 +- .../apache/bcel/classfile/FieldOrMethod.java | 14 +-- .../org/apache/bcel/classfile/JavaClass.java | 14 +-- .../org/apache/bcel/classfile/Module.java | 106 +++++++++--------- .../apache/bcel/classfile/ModuleExports.java | 74 ++++++------ .../apache/bcel/classfile/ModuleOpens.java | 74 ++++++------ .../apache/bcel/classfile/ModuleProvides.java | 66 +++++------ .../apache/bcel/classfile/ModuleRequires.java | 58 +++++----- .../apache/bcel/AnonymousClassTestCase.java | 14 +-- .../bcel/LocalVariableTypeTableTestCase.java | 32 +++--- 10 files changed, 230 insertions(+), 230 deletions(-) diff --git a/src/examples/Mini/Environment.java b/src/examples/Mini/Environment.java index 49c36833b3..ead9561424 100644 --- a/src/examples/Mini/Environment.java +++ b/src/examples/Mini/Environment.java @@ -35,14 +35,14 @@ public Environment() { this(SIZE); } - public Environment(final int size) { - table = new ConcurrentHashMap<>(size); - } - private Environment(final ConcurrentHashMap table) { this.table = table; } + public Environment(final int size) { + table = new ConcurrentHashMap<>(size); + } + @Override public Object clone() { return new Environment(new ConcurrentHashMap<>(table)); diff --git a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java index f67c1be725..bc13135a73 100644 --- a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java +++ b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java @@ -164,13 +164,6 @@ public AnnotationEntry[] getAnnotationEntries() { return annotationEntries; } - /** - * @return Collection of object attributes. - */ - public final Attribute[] getAttributes() { - return attributes; - } - /** * Gets attribute for given tag. * @return Attribute for given tag, null if not found. @@ -187,6 +180,13 @@ public final T getAttribute(final byte tag) { return null; } + /** + * @return Collection of object attributes. + */ + public final Attribute[] getAttributes() { + return attributes; + } + /** * @return Constant pool used by this object. */ diff --git a/src/main/java/org/apache/bcel/classfile/JavaClass.java b/src/main/java/org/apache/bcel/classfile/JavaClass.java index fa49fbc398..93bfbe11a8 100644 --- a/src/main/java/org/apache/bcel/classfile/JavaClass.java +++ b/src/main/java/org/apache/bcel/classfile/JavaClass.java @@ -482,13 +482,6 @@ public AnnotationEntry[] getAnnotationEntries() { return annotations; } - /** - * @return Attributes of the class. - */ - public Attribute[] getAttributes() { - return attributes; - } - /** * Gets attribute for given tag. * @return Attribute for given tag, null if not found. @@ -505,6 +498,13 @@ public final T getAttribute(final byte tag) { return null; } + /** + * @return Attributes of the class. + */ + public Attribute[] getAttributes() { + return attributes; + } + /** * @return class in binary format */ diff --git a/src/main/java/org/apache/bcel/classfile/Module.java b/src/main/java/org/apache/bcel/classfile/Module.java index 5915522c16..3e8c9fb9b1 100644 --- a/src/main/java/org/apache/bcel/classfile/Module.java +++ b/src/main/java/org/apache/bcel/classfile/Module.java @@ -40,15 +40,23 @@ public final class Module extends Attribute { */ public static final String EXTENSION = ".jmod"; + private static String getClassNameAtIndex(final ConstantPool cp, final int index, final boolean compactClassName) { + final String className = cp.getConstantString(index, Const.CONSTANT_Class); + if (compactClassName) { + return Utility.compactClassName(className, false); + } + return className; + } private final int moduleNameIndex; private final int moduleFlags; - private final int moduleVersionIndex; + private final int moduleVersionIndex; private ModuleRequires[] requiresTable; private ModuleExports[] exportsTable; private ModuleOpens[] opensTable; private final int usesCount; private final int[] usesIndex; + private ModuleProvides[] providesTable; /** @@ -109,58 +117,6 @@ public void accept(final Visitor v) { v.visitModule(this); } - /** - * Gets version for this module. - * @param cp Array of constants - * @return version from constant pool, "0" if version index is 0 - * @since 6.10.0 - */ - public String getVersion(final ConstantPool cp) { - return moduleVersionIndex == 0 ? "0" : cp.getConstantString(moduleVersionIndex, Const.CONSTANT_Utf8); - } - - /** - * Gets flags for this module. - * @return module flags - * @since 6.10.0 - */ - public int getModuleFlags() { - return moduleFlags; - } - - /** - * Gets module name. - * @param cp Array of constants - * @return module name - * @since 6.10.0 - */ - public String getModuleName(final ConstantPool cp) { - return cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module); - } - - /** - * Gets the array of class names for this module's uses. - * @param constantPool Array of constants usually obtained from the ClassFile object - * @param compactClassName false for original constant pool value, true to replace '/' with '.' - * @return array of used class names - * @since 6.10.0 - */ - public String[] getUsedClassNames(final ConstantPool constantPool, final boolean compactClassName) { - final String[] usedClassNames = new String[usesCount]; - for (int i = 0; i < usesCount; i++) { - usedClassNames[i] = getClassNameAtIndex(constantPool, usesIndex[i], compactClassName); - } - return usedClassNames; - } - - private static String getClassNameAtIndex(final ConstantPool cp, final int index, final boolean compactClassName) { - final String className = cp.getConstantString(index, Const.CONSTANT_Class); - if (compactClassName) { - return Utility.compactClassName(className, false); - } - return className; - } - /** * @return deep copy of this attribute */ @@ -232,6 +188,25 @@ public ModuleExports[] getExportsTable() { return exportsTable; } + /** + * Gets flags for this module. + * @return module flags + * @since 6.10.0 + */ + public int getModuleFlags() { + return moduleFlags; + } + + /** + * Gets module name. + * @param cp Array of constants + * @return module name + * @since 6.10.0 + */ + public String getModuleName(final ConstantPool cp) { + return cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module); + } + /** * @return table of provided interfaces * @see ModuleOpens @@ -256,6 +231,31 @@ public ModuleRequires[] getRequiresTable() { return requiresTable; } + /** + * Gets the array of class names for this module's uses. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @param compactClassName false for original constant pool value, true to replace '/' with '.' + * @return array of used class names + * @since 6.10.0 + */ + public String[] getUsedClassNames(final ConstantPool constantPool, final boolean compactClassName) { + final String[] usedClassNames = new String[usesCount]; + for (int i = 0; i < usesCount; i++) { + usedClassNames[i] = getClassNameAtIndex(constantPool, usesIndex[i], compactClassName); + } + return usedClassNames; + } + + /** + * Gets version for this module. + * @param cp Array of constants + * @return version from constant pool, "0" if version index is 0 + * @since 6.10.0 + */ + public String getVersion(final ConstantPool cp) { + return moduleVersionIndex == 0 ? "0" : cp.getConstantString(moduleVersionIndex, Const.CONSTANT_Utf8); + } + /** * @return String representation, i.e., a list of packages. */ diff --git a/src/main/java/org/apache/bcel/classfile/ModuleExports.java b/src/main/java/org/apache/bcel/classfile/ModuleExports.java index 5653e82de8..34460c4205 100644 --- a/src/main/java/org/apache/bcel/classfile/ModuleExports.java +++ b/src/main/java/org/apache/bcel/classfile/ModuleExports.java @@ -32,9 +32,13 @@ */ public final class ModuleExports implements Cloneable, Node { + private static String getToModuleNameAtIndex(final ConstantPool constantPool, final int index) { + return constantPool.getConstantString(index, Const.CONSTANT_Module); + } private final int exportsIndex; // points to CONSTANT_Package_info private final int exportsFlags; private final int exportsToCount; + private final int[] exportsToIndex; // points to CONSTANT_Module_info /** @@ -53,43 +57,6 @@ public final class ModuleExports implements Cloneable, Node { } } - /** - * Gets the flags for this ModuleExports. - * @return the exportsFlags - * @since 6.10.0 - */ - public int getExportsFlags() { - return exportsFlags; - } - - /** - * Gets an array of module names for this ModuleExports. - * @param constantPool Array of constants usually obtained from the ClassFile object - * @return array of module names following 'exports to' - * @since 6.10.0 - */ - public String[] getToModuleNames(final ConstantPool constantPool) { - final String[] toModuleNames = new String[exportsToCount]; - for (int i = 0; i < exportsToCount; i++) { - toModuleNames[i] = getToModuleNameAtIndex(constantPool, exportsToIndex[i]); - } - return toModuleNames; - } - - private static String getToModuleNameAtIndex(final ConstantPool constantPool, final int index) { - return constantPool.getConstantString(index, Const.CONSTANT_Module); - } - - /** - * Gets the exported package name. - * @param constantPool the constant pool from the ClassFile - * @return the exported package name - * @since 6.10.0 - */ - public String getPackageName(final ConstantPool constantPool) { - return constantPool.constantToString(exportsIndex, Const.CONSTANT_Package); - } - /** * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. @@ -128,6 +95,39 @@ public void dump(final DataOutputStream file) throws IOException { } } + /** + * Gets the flags for this ModuleExports. + * @return the exportsFlags + * @since 6.10.0 + */ + public int getExportsFlags() { + return exportsFlags; + } + + /** + * Gets the exported package name. + * @param constantPool the constant pool from the ClassFile + * @return the exported package name + * @since 6.10.0 + */ + public String getPackageName(final ConstantPool constantPool) { + return constantPool.constantToString(exportsIndex, Const.CONSTANT_Package); + } + + /** + * Gets an array of module names for this ModuleExports. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @return array of module names following 'exports to' + * @since 6.10.0 + */ + public String[] getToModuleNames(final ConstantPool constantPool) { + final String[] toModuleNames = new String[exportsToCount]; + for (int i = 0; i < exportsToCount; i++) { + toModuleNames[i] = getToModuleNameAtIndex(constantPool, exportsToIndex[i]); + } + return toModuleNames; + } + /** * @return String representation */ diff --git a/src/main/java/org/apache/bcel/classfile/ModuleOpens.java b/src/main/java/org/apache/bcel/classfile/ModuleOpens.java index f8da77c7c1..c3b916eb93 100644 --- a/src/main/java/org/apache/bcel/classfile/ModuleOpens.java +++ b/src/main/java/org/apache/bcel/classfile/ModuleOpens.java @@ -32,9 +32,13 @@ */ public final class ModuleOpens implements Cloneable, Node { + private static String getToModuleNameAtIndex(final ConstantPool constantPool, final int index) { + return constantPool.getConstantString(index, Const.CONSTANT_Module); + } private final int opensIndex; // points to CONSTANT_Package_info private final int opensFlags; private final int opensToCount; + private final int[] opensToIndex; // points to CONSTANT_Module_info /** @@ -53,43 +57,6 @@ public final class ModuleOpens implements Cloneable, Node { } } - /** - * Gets the flags for this ModuleOpens. - * @return the opensFlags - * @since 6.10.0 - */ - public int getOpensFlags() { - return opensFlags; - } - - /** - * Gets an array of module names for this ModuleOpens. - * @param constantPool Array of constants usually obtained from the ClassFile object - * @return array of module names following 'opens to' - * @since 6.10.0 - */ - public String[] getToModuleNames(final ConstantPool constantPool) { - final String[] toModuleNames = new String[opensToCount]; - for (int i = 0; i < opensToCount; i++) { - toModuleNames[i] = getToModuleNameAtIndex(constantPool, opensToIndex[i]); - } - return toModuleNames; - } - - private static String getToModuleNameAtIndex(final ConstantPool constantPool, final int index) { - return constantPool.getConstantString(index, Const.CONSTANT_Module); - } - - /** - * Gets the opened package name. - * @param constantPool the constant pool from the ClassFile - * @return the opened package name - * @since 6.10.0 - */ - public String getPackageName(final ConstantPool constantPool) { - return constantPool.constantToString(opensIndex, Const.CONSTANT_Package); - } - /** * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. @@ -128,6 +95,39 @@ public void dump(final DataOutputStream file) throws IOException { } } + /** + * Gets the flags for this ModuleOpens. + * @return the opensFlags + * @since 6.10.0 + */ + public int getOpensFlags() { + return opensFlags; + } + + /** + * Gets the opened package name. + * @param constantPool the constant pool from the ClassFile + * @return the opened package name + * @since 6.10.0 + */ + public String getPackageName(final ConstantPool constantPool) { + return constantPool.constantToString(opensIndex, Const.CONSTANT_Package); + } + + /** + * Gets an array of module names for this ModuleOpens. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @return array of module names following 'opens to' + * @since 6.10.0 + */ + public String[] getToModuleNames(final ConstantPool constantPool) { + final String[] toModuleNames = new String[opensToCount]; + for (int i = 0; i < opensToCount; i++) { + toModuleNames[i] = getToModuleNameAtIndex(constantPool, opensToIndex[i]); + } + return toModuleNames; + } + /** * @return String representation */ diff --git a/src/main/java/org/apache/bcel/classfile/ModuleProvides.java b/src/main/java/org/apache/bcel/classfile/ModuleProvides.java index 8c88f1709a..108b5dc6fe 100644 --- a/src/main/java/org/apache/bcel/classfile/ModuleProvides.java +++ b/src/main/java/org/apache/bcel/classfile/ModuleProvides.java @@ -32,8 +32,16 @@ */ public final class ModuleProvides implements Cloneable, Node { + private static String getImplementationClassNameAtIndex(final ConstantPool constantPool, final int index, final boolean compactClassName) { + final String className = constantPool.getConstantString(index, Const.CONSTANT_Class); + if (compactClassName) { + return Utility.compactClassName(className, false); + } + return className; + } private final int providesIndex; // points to CONSTANT_Class_info private final int providesWithCount; + private final int[] providesWithIndex; // points to CONSTANT_Class_info /** @@ -51,39 +59,6 @@ public final class ModuleProvides implements Cloneable, Node { } } - /** - * Gets the array of implementation class names for this ModuleProvides. - * @param constantPool Array of constants usually obtained from the ClassFile object - * @param compactClassName false for original constant pool value, true to replace '/' with '.' - * @return array of implementation class names - * @since 6.10.0 - */ - public String[] getImplementationClassNames(final ConstantPool constantPool, final boolean compactClassName) { - final String[] implementationClassNames = new String[providesWithCount]; - for (int i = 0; i < providesWithCount; i++) { - implementationClassNames[i] = getImplementationClassNameAtIndex(constantPool, providesWithIndex[i], compactClassName); - } - return implementationClassNames; - } - - private static String getImplementationClassNameAtIndex(final ConstantPool constantPool, final int index, final boolean compactClassName) { - final String className = constantPool.getConstantString(index, Const.CONSTANT_Class); - if (compactClassName) { - return Utility.compactClassName(className, false); - } - return className; - } - - /** - * Gets the interface name for this ModuleProvides. - * @param constantPool Array of constants usually obtained from the ClassFile object - * @return interface name - * @since 6.10.0 - */ - public String getInterfaceName(final ConstantPool constantPool) { - return constantPool.constantToString(providesIndex, Const.CONSTANT_Class); - } - /** * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. @@ -121,6 +96,31 @@ public void dump(final DataOutputStream file) throws IOException { } } + /** + * Gets the array of implementation class names for this ModuleProvides. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @param compactClassName false for original constant pool value, true to replace '/' with '.' + * @return array of implementation class names + * @since 6.10.0 + */ + public String[] getImplementationClassNames(final ConstantPool constantPool, final boolean compactClassName) { + final String[] implementationClassNames = new String[providesWithCount]; + for (int i = 0; i < providesWithCount; i++) { + implementationClassNames[i] = getImplementationClassNameAtIndex(constantPool, providesWithIndex[i], compactClassName); + } + return implementationClassNames; + } + + /** + * Gets the interface name for this ModuleProvides. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @return interface name + * @since 6.10.0 + */ + public String getInterfaceName(final ConstantPool constantPool) { + return constantPool.constantToString(providesIndex, Const.CONSTANT_Class); + } + /** * @return String representation */ diff --git a/src/main/java/org/apache/bcel/classfile/ModuleRequires.java b/src/main/java/org/apache/bcel/classfile/ModuleRequires.java index 678b0843cd..5c97e70c7a 100644 --- a/src/main/java/org/apache/bcel/classfile/ModuleRequires.java +++ b/src/main/java/org/apache/bcel/classfile/ModuleRequires.java @@ -48,35 +48,6 @@ public final class ModuleRequires implements Cloneable, Node { requiresVersionIndex = file.readUnsignedShort(); } - /** - * Gets the flags for this ModuleRequires. - * @return the requiresFlags - * @since 6.10.0 - */ - public int getRequiresFlags() { - return requiresFlags; - } - - /** - * Gets the required version from the constant pool. - * @param constantPool Array of constants usually obtained from the ClassFile object - * @return required version, "0" if version index is 0. - * @since 6.10.0 - */ - public String getVersion(final ConstantPool constantPool) { - return requiresVersionIndex == 0 ? "0" : constantPool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8); - } - - /** - * Gets the module name from the constant pool. - * @param constantPool Array of constants usually obtained from the ClassFile object - * @return module name - * @since 6.10.0 - */ - public String getModuleName(final ConstantPool constantPool) { - return constantPool.constantToString(requiresIndex, Const.CONSTANT_Module); - } - /** * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. @@ -112,6 +83,35 @@ public void dump(final DataOutputStream file) throws IOException { file.writeShort(requiresVersionIndex); } + /** + * Gets the module name from the constant pool. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @return module name + * @since 6.10.0 + */ + public String getModuleName(final ConstantPool constantPool) { + return constantPool.constantToString(requiresIndex, Const.CONSTANT_Module); + } + + /** + * Gets the flags for this ModuleRequires. + * @return the requiresFlags + * @since 6.10.0 + */ + public int getRequiresFlags() { + return requiresFlags; + } + + /** + * Gets the required version from the constant pool. + * @param constantPool Array of constants usually obtained from the ClassFile object + * @return required version, "0" if version index is 0. + * @since 6.10.0 + */ + public String getVersion(final ConstantPool constantPool) { + return requiresVersionIndex == 0 ? "0" : constantPool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8); + } + /** * @return String representation */ diff --git a/src/test/java/org/apache/bcel/AnonymousClassTestCase.java b/src/test/java/org/apache/bcel/AnonymousClassTestCase.java index ed6f0dd7f4..b6420642a4 100644 --- a/src/test/java/org/apache/bcel/AnonymousClassTestCase.java +++ b/src/test/java/org/apache/bcel/AnonymousClassTestCase.java @@ -43,13 +43,6 @@ public void testNamedInnerClassIsNotAnonymous() throws ClassNotFoundException { assertTrue(clazz.isNested(), "regular inner classes are nested"); } - @Test - public void testRegularClassIsNotAnonymous() throws ClassNotFoundException { - final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.AnonymousClassTest"); - assertFalse(clazz.isAnonymous(), "regular outer classes are not anonymous"); - assertFalse(clazz.isNested(), "regular outer classes are not nested"); - } - @Test public void testRegularClassInnerClasses() throws ClassNotFoundException { final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.AnonymousClassTest"); @@ -59,6 +52,13 @@ public void testRegularClassInnerClasses() throws ClassNotFoundException { assertNull(Repository.lookupClass(EmptyClass.class).getAttribute(Const.ATTR_INNER_CLASSES)); } + @Test + public void testRegularClassIsNotAnonymous() throws ClassNotFoundException { + final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.AnonymousClassTest"); + assertFalse(clazz.isAnonymous(), "regular outer classes are not anonymous"); + assertFalse(clazz.isNested(), "regular outer classes are not nested"); + } + @Test public void testStaticInnerClassIsNotAnonymous() throws ClassNotFoundException { final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.AnonymousClassTest$Y"); diff --git a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java index 6855069e3e..7dce3b6577 100644 --- a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java +++ b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java @@ -132,22 +132,6 @@ public InstructionList makeWillBeAddedInstructionList(final MethodGen methodGen, return createPrintln(methodGen.getConstantPool(), instruction); } - @Test - public void testWithGenericArguement() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { - final String targetClass = PACKAGE_BASE_NAME + ".data.SimpleClassHasMethodIncludeGenericArgument"; - final TestClassLoader loader = new TestClassLoader(getClass().getClassLoader()); - final Class cls = loader.findClass(targetClass, getBytesFromClass(targetClass)); - - java.lang.reflect.Method method = cls.getDeclaredMethod("a", String.class, List.class); - method.invoke(null, "a1", new LinkedList<>()); - method = cls.getDeclaredMethod("b", String.class, List.class); - method.invoke(null, "b1", new LinkedList<>()); - method = cls.getDeclaredMethod("c", String.class, String.class); - method.invoke(null, "c1", "c2"); - method = cls.getDeclaredMethod("d", List.class, String.class); - method.invoke(null, new LinkedList<>(), "d2"); - } - @Test public void testGetLocalVariableTypeTable() throws ClassNotFoundException, NoSuchMethodException, SecurityException { final JavaClass testJavaClass = getTestJavaClass("org/apache/commons/lang3/function/TriFunction"); @@ -163,4 +147,20 @@ public void testGetLocalVariableTypeTable() throws ClassNotFoundException, NoSuc } assertNull(Repository.lookupClass(Object.class).getMethod(Object.class.getMethod("toString")).getLocalVariableTypeTable()); } + + @Test + public void testWithGenericArguement() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { + final String targetClass = PACKAGE_BASE_NAME + ".data.SimpleClassHasMethodIncludeGenericArgument"; + final TestClassLoader loader = new TestClassLoader(getClass().getClassLoader()); + final Class cls = loader.findClass(targetClass, getBytesFromClass(targetClass)); + + java.lang.reflect.Method method = cls.getDeclaredMethod("a", String.class, List.class); + method.invoke(null, "a1", new LinkedList<>()); + method = cls.getDeclaredMethod("b", String.class, List.class); + method.invoke(null, "b1", new LinkedList<>()); + method = cls.getDeclaredMethod("c", String.class, String.class); + method.invoke(null, "c1", "c2"); + method = cls.getDeclaredMethod("d", List.class, String.class); + method.invoke(null, new LinkedList<>(), "d2"); + } } From 48cd4799c5d4146b73cfc9e5eeeebc5a505a920e Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 22 Jun 2024 14:57:22 -0400 Subject: [PATCH 081/114] Sort imports --- src/examples/ClassDumper.java | 2 -- .../bcel/LocalVariableTypeTableTestCase.java | 6 +++--- .../bcel/generic/FieldAnnotationsTestCase.java | 16 ++++++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/examples/ClassDumper.java b/src/examples/ClassDumper.java index 4822dd7fb9..68dd1bd849 100644 --- a/src/examples/ClassDumper.java +++ b/src/examples/ClassDumper.java @@ -25,8 +25,6 @@ import org.apache.bcel.classfile.ClassFormatException; import org.apache.bcel.classfile.Constant; import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.Field; -import org.apache.bcel.classfile.Method; import org.apache.bcel.util.BCELifier; /** diff --git a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java index 7dce3b6577..0079a20ed5 100644 --- a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java +++ b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java @@ -16,6 +16,9 @@ */ package org.apache.bcel; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.lang.reflect.InvocationTargetException; import java.util.LinkedList; import java.util.List; @@ -35,9 +38,6 @@ import org.apache.bcel.generic.Type; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - public class LocalVariableTypeTableTestCase extends AbstractTestCase { public class TestClassLoader extends ClassLoader { diff --git a/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java b/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java index 5ba8db0f7f..32794cdc81 100644 --- a/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java +++ b/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java @@ -17,6 +17,14 @@ package org.apache.bcel.generic; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.File; +import java.io.IOException; + import org.apache.bcel.AbstractTestCase; import org.apache.bcel.Const; import org.apache.bcel.classfile.AnnotationEntry; @@ -26,14 +34,6 @@ import org.apache.bcel.util.SyntheticRepository; import org.junit.jupiter.api.Test; -import java.io.File; -import java.io.IOException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - public class FieldAnnotationsTestCase extends AbstractTestCase { // helper methods public void checkAnnotatedField(final JavaClass clazz, final String fieldname, final String AnnotationEntryName, final String AnnotationEntryElementName, From 59ece03362b1a5559ed2e79b0a88a7919c2b9dcc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:23:08 -0400 Subject: [PATCH 082/114] Bump github/codeql-action from 3.25.10 to 3.25.11 (#329) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.10 to 3.25.11. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/23acc5c183826b7a8a97bce3cecc52db901f8251...b611370bb5703a7efb587f9d136a52ea24c5c38c) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8cffd66e8e..4f743b02fe 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10 + uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10 + uses: github/codeql-action/autobuild@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10 + uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index ff25485bde..51cf0505f2 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # 3.25.10 + uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # 3.25.11 with: sarif_file: results.sarif From aca584fbe4ca2cfb82edcd75f322558976a25b81 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 29 Jun 2024 08:00:01 -0400 Subject: [PATCH 083/114] Drop CodeQL It now requires an API key and a login to view reports --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 243719864a..f2449c51e0 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,6 @@ Apache Commons BCEL [![Coverage Status](https://codecov.io/gh/apache/commons-bcel/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-bcel) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/badge.svg?gav=true)](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/?gav=true) [![Javadocs](https://javadoc.io/badge/org.apache.bcel/bcel/6.9.0.svg)](https://javadoc.io/doc/org.apache.bcel/bcel/6.9.0) -[![CodeQL](https://github.com/apache/commons-bcel/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/apache/commons-bcel/actions/workflows/codeql-analysis.yml) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/apache/commons-bcel/badge)](https://api.securityscorecards.dev/projects/github.com/apache/commons-bcel) Apache Commons Bytecode Engineering Library From 6fff303bdbae00452ee5623760007704a7c1763a Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 29 Jun 2024 08:08:28 -0400 Subject: [PATCH 084/114] Drop CodeQL - It now requires an API key and a login to view reports - Instead, use 'mvn clean install site -P jacoco' to view JaCoCo HTML reports --- .github/workflows/codeql-analysis.yml | 85 --------------------------- 1 file changed, 85 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 4f743b02fe..0000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,85 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: "CodeQL" - -on: - push: - branches: [ master ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] - schedule: - - cron: '33 9 * * 4' - -permissions: - contents: read - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'java' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://git.io/codeql-language-support - - steps: - - name: Checkout repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - persist-credentials: false - - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 From 11dd3050b4f9d6201f3f87953fd95d105440d5a4 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 29 Jun 2024 10:45:56 -0400 Subject: [PATCH 085/114] Revert "Drop CodeQL" This reverts commit 6fff303bdbae00452ee5623760007704a7c1763a. --- .github/workflows/codeql-analysis.yml | 85 +++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000000..4f743b02fe --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,85 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '33 9 * * 4' + +permissions: + contents: read + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + persist-credentials: false + - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 From 413fc4efacb38f0e75c0275b49d0eec8f84b1394 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 29 Jun 2024 10:45:56 -0400 Subject: [PATCH 086/114] Revert "Drop CodeQL" This reverts commit aca584fbe4ca2cfb82edcd75f322558976a25b81. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f2449c51e0..243719864a 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Apache Commons BCEL [![Coverage Status](https://codecov.io/gh/apache/commons-bcel/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-bcel) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/badge.svg?gav=true)](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/?gav=true) [![Javadocs](https://javadoc.io/badge/org.apache.bcel/bcel/6.9.0.svg)](https://javadoc.io/doc/org.apache.bcel/bcel/6.9.0) +[![CodeQL](https://github.com/apache/commons-bcel/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/apache/commons-bcel/actions/workflows/codeql-analysis.yml) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/apache/commons-bcel/badge)](https://api.securityscorecards.dev/projects/github.com/apache/commons-bcel) Apache Commons Bytecode Engineering Library From 335e4910c9d40e4fb11f06583fff54c9a6bf966e Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Sat, 29 Jun 2024 14:21:55 -0400 Subject: [PATCH 087/114] Drop codecov.io - It now requires an API key and a login to view reports - Instead, use 'mvn clean install site -P jacoco' to view JaCoCo HTML reports --- .github/workflows/coverage.yml | 52 ---------------------------------- README.md | 1 - 2 files changed, 53 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 30ad32e24a..0000000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: Coverage - -on: [push, pull_request] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - java: [ 8, 11 ] - - steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - persist-credentials: false - - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 - with: - distribution: 'temurin' - java-version: ${{ matrix.java }} - - name: Build with Maven - run: mvn --show-version --batch-mode --no-transfer-progress install jacoco:report -DdataFile=jacoco_jdk${{ matrix.java }}.exec - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 - with: - files: ./target/site/jacoco/jacoco.xml diff --git a/README.md b/README.md index 243719864a..9c4aa0a87a 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,6 @@ Apache Commons BCEL =================== [![Java CI](https://github.com/apache/commons-bcel/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-bcel/actions/workflows/maven.yml) -[![Coverage Status](https://codecov.io/gh/apache/commons-bcel/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-bcel) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/badge.svg?gav=true)](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/?gav=true) [![Javadocs](https://javadoc.io/badge/org.apache.bcel/bcel/6.9.0.svg)](https://javadoc.io/doc/org.apache.bcel/bcel/6.9.0) [![CodeQL](https://github.com/apache/commons-bcel/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/apache/commons-bcel/actions/workflows/codeql-analysis.yml) From bf5323de7c032804eb2821b05d317c935a0ca917 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:48:00 -0400 Subject: [PATCH 088/114] Bump actions/upload-artifact from 4.3.3 to 4.3.4 (#330) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.3 to 4.3.4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/65462800fd760344b1a7b4382951275a0abb4808...0b2256b8c012f0828dc542b3febcab082c67f72b) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/scorecards-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 51cf0505f2..93717531c6 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -57,7 +57,7 @@ jobs: publish_results: true - name: "Upload artifact" - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 with: name: SARIF file path: results.sarif From d68b1b2d894c4e53fc0658f5770ccb459e7437a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 18:01:03 -0400 Subject: [PATCH 089/114] Bump org.codehaus.mojo:taglist-maven-plugin from 3.0.0 to 3.1.0 (#331) Bumps [org.codehaus.mojo:taglist-maven-plugin](https://github.com/mojohaus/taglist-maven-plugin) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/mojohaus/taglist-maven-plugin/releases) - [Commits](https://github.com/mojohaus/taglist-maven-plugin/compare/taglist-maven-plugin-3.0.0...3.1.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:taglist-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1e3ec8f0fe..b26bf7ec56 100644 --- a/pom.xml +++ b/pom.xml @@ -297,7 +297,7 @@ org.codehaus.mojo taglist-maven-plugin - 3.0.0 + 3.1.0 TODO From d3dcb081603210f241d4ac7c102dd2a2230d6ba8 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 5 Jul 2024 18:01:38 -0400 Subject: [PATCH 090/114] Bump org.codehaus.mojo:taglist-maven-plugin from 3.0.0 to 3.1.0 #331 --- src/changes/changes.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b54aaafaea..1b47e750cd 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -79,7 +79,8 @@ The type attribute can be add,update,fix,remove. Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.0 #322. Bump tests from org.jetbrains.kotlin:kotlin-stdlib 1.9.23 to 2.0.0 #309, #318. Bump tests from org.apache.commons:commons-collections4 4.4 to 4.5.0-M2. - Bump org.apache.commons:commons-parent from 69 to 71. + Bump org.apache.commons:commons-parent from 69 to 71. + Bump org.codehaus.mojo:taglist-maven-plugin from 3.0.0 to 3.1.0 #331. From 05530835b9e067a5293a6aadf2cb8eaafa553972 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:37:51 -0400 Subject: [PATCH 091/114] Remove trailing whitespace --- src/examples/Mini/ASTFunDecl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/examples/Mini/ASTFunDecl.java b/src/examples/Mini/ASTFunDecl.java index a3f246d7c5..f404c8aa0e 100644 --- a/src/examples/Mini/ASTFunDecl.java +++ b/src/examples/Mini/ASTFunDecl.java @@ -111,7 +111,7 @@ private static void optimizeIFs(final InstructionList il) { final InstructionTargeter[] targeters = target.getTargeters(); for (final InstructionTargeter targeter : targeters) { - // TODO Is this really identity equality and not object equality? + // TODO Is this really identity equality and not object equality? if (target != match[4] || targeter != match[2]) { System.err.println("Unexpected: " + e); } From 402e2422eebc4a54d78d8dadad66f1c2fb9bb7a1 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:38:47 -0400 Subject: [PATCH 092/114] Remove redundant keywords Move instance variable to local --- src/examples/ClassDumper.java | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/examples/ClassDumper.java b/src/examples/ClassDumper.java index 68dd1bd849..d4d810c0e7 100644 --- a/src/examples/ClassDumper.java +++ b/src/examples/ClassDumper.java @@ -34,7 +34,6 @@ final class ClassDumper { private final FileImageInputStream file; private final String fileName; - private int classNameIndex; private int superclassNameIndex; private int major; private int minor; // Compiler version @@ -57,7 +56,7 @@ public ClassDumper(final FileImageInputStream file, final String fileName) { this.file = file; } - private final String constantToString(final int index) { + private String constantToString(final int index) { final Constant c = constantItems[index]; return constantPool.constantToString(c); } @@ -106,7 +105,7 @@ public void dump() throws IOException, ClassFormatException { * @throws IOException * @throws ClassFormatException */ - private final void processAttributes() throws IOException, ClassFormatException { + private void processAttributes() throws IOException, ClassFormatException { final int attributesCount = file.readUnsignedShort(); attributes = new Attribute[attributesCount]; @@ -128,7 +127,7 @@ private final void processAttributes() throws IOException, ClassFormatException * @throws IOException * @throws ClassFormatException */ - private final void processClassInfo() throws IOException, ClassFormatException { + private void processClassInfo() throws IOException, ClassFormatException { accessFlags = file.readUnsignedShort(); /* * Interfaces are implicitly abstract, the flag should be set according to the JVM specification. @@ -142,7 +141,7 @@ private final void processClassInfo() throws IOException, ClassFormatException { System.out.printf("%nClass info:%n"); System.out.println(" flags: " + BCELifier.printFlags(accessFlags, BCELifier.FLAGS.CLASS)); - classNameIndex = file.readUnsignedShort(); + int classNameIndex = file.readUnsignedShort(); System.out.printf(" this_class: %d (", classNameIndex); System.out.println(constantToString(classNameIndex) + ")"); @@ -160,7 +159,7 @@ private final void processClassInfo() throws IOException, ClassFormatException { * @throws IOException * @throws ClassFormatException */ - private final void processConstantPool() throws IOException, ClassFormatException { + private void processConstantPool() throws IOException, ClassFormatException { byte tag; final int constantPoolCount = file.readUnsignedShort(); constantItems = new Constant[constantPoolCount]; @@ -196,7 +195,7 @@ private final void processConstantPool() throws IOException, ClassFormatExceptio * @throws IOException * @throws ClassFormatException */ - private final void processFieldOrMethod() throws IOException, ClassFormatException { + private void processFieldOrMethod() throws IOException, ClassFormatException { final int accessFlags = file.readUnsignedShort(); final int nameIndex = file.readUnsignedShort(); System.out.printf(" nameIndex: %d (", nameIndex); @@ -245,7 +244,7 @@ private final void processFieldOrMethod() throws IOException, ClassFormatExcepti * @throws IOException * @throws ClassFormatException */ - private final void processFields() throws IOException, ClassFormatException { + private void processFields() throws IOException, ClassFormatException { final int fieldsCount = file.readUnsignedShort(); // fields = new Field[fieldsCount]; @@ -266,7 +265,7 @@ private final void processFields() throws IOException, ClassFormatException { * @throws IOException * @throws ClassFormatException */ - private final void processID() throws IOException, ClassFormatException { + private void processID() throws IOException, ClassFormatException { final int magic = file.readInt(); if (magic != Const.JVM_CLASSFILE_MAGIC) { throw new ClassFormatException(fileName + " is not a Java .class file"); @@ -283,7 +282,7 @@ private final void processID() throws IOException, ClassFormatException { * @throws IOException * @throws ClassFormatException */ - private final void processInterfaces() throws IOException, ClassFormatException { + private void processInterfaces() throws IOException, ClassFormatException { final int interfacesCount = file.readUnsignedShort(); interfaces = new int[interfacesCount]; @@ -309,7 +308,7 @@ private final void processInterfaces() throws IOException, ClassFormatException * @throws IOException * @throws ClassFormatException */ - private final void processMethods() throws IOException, ClassFormatException { + private void processMethods() throws IOException, ClassFormatException { final int methodsCount = file.readUnsignedShort(); // methods = new Method[methodsCount]; @@ -329,7 +328,7 @@ private final void processMethods() throws IOException, ClassFormatException { * @throws IOException * @throws ClassFormatException */ - private final void processVersion() throws IOException, ClassFormatException { + private void processVersion() throws IOException, ClassFormatException { minor = file.readUnsignedShort(); System.out.printf(" minor version: %s%n", minor); From 3a315629293cb5373498bda6e429a817e1414186 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:39:00 -0400 Subject: [PATCH 093/114] Remove redundant keywords --- .../org/apache/bcel/verifier/structurals/ControlFlowGraph.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java b/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java index e2be0bf5b0..c67c7875ba 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java @@ -238,7 +238,7 @@ public ExceptionHandler[] getExceptionHandlers() { * the surrounding ControlFlowGraph. */ private String getExecutionChain() { - final StringBuilder s = new StringBuilder(this.toString()); + final StringBuilder s = new StringBuilder(toString()); for (int i = executionPredecessors.size() - 1; i >= 0; i--) { s.insert(0, executionPredecessors.get(i) + "\n"); } From 854ace8bb7d4e542324928b4ba585b13f8a5293c Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:39:11 -0400 Subject: [PATCH 094/114] Remove redundant keywords --- src/main/java/org/apache/bcel/generic/Instruction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/generic/Instruction.java b/src/main/java/org/apache/bcel/generic/Instruction.java index 2e8fa151cc..1d82913202 100644 --- a/src/main/java/org/apache/bcel/generic/Instruction.java +++ b/src/main/java/org/apache/bcel/generic/Instruction.java @@ -456,7 +456,7 @@ public int consumeStack(final ConstantPoolGen cpg) { public Instruction copy() { Instruction i = null; // "Constant" instruction, no need to duplicate - if (InstructionConst.getInstruction(this.getOpcode()) != null) { + if (InstructionConst.getInstruction(getOpcode()) != null) { i = this; } else { try { From 8cf581884ae78e07620506b2239c2a7aa8aba9a9 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:39:24 -0400 Subject: [PATCH 095/114] Remove trailing whitespace --- src/examples/JasminVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/examples/JasminVisitor.java b/src/examples/JasminVisitor.java index d17a3528e7..12f4a92282 100644 --- a/src/examples/JasminVisitor.java +++ b/src/examples/JasminVisitor.java @@ -78,7 +78,7 @@ public static void main(final String[] argv) throws Exception { if (!path.isEmpty()) { final File file = new File(path); if (!file.mkdirs()) { - System.err.println("Couldn't create directories for " + file); + System.err.println("Couldn't create directories for " + file); } } From 77651570baad53869d70ecf58d1adc1ea619a6ad Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:39:35 -0400 Subject: [PATCH 096/114] Remove redundant keywords --- src/main/java/org/apache/bcel/classfile/JavaClass.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/bcel/classfile/JavaClass.java b/src/main/java/org/apache/bcel/classfile/JavaClass.java index 93bfbe11a8..29f76eedf3 100644 --- a/src/main/java/org/apache/bcel/classfile/JavaClass.java +++ b/src/main/java/org/apache/bcel/classfile/JavaClass.java @@ -719,7 +719,7 @@ public boolean implementationOf(final JavaClass inter) throws ClassNotFoundExcep if (!inter.isInterface()) { throw new IllegalArgumentException(inter.getClassName() + " is no interface"); } - if (this.equals(inter)) { + if (equals(inter)) { return true; } final JavaClass[] superInterfaces = getAllInterfaces(); @@ -738,7 +738,7 @@ public boolean implementationOf(final JavaClass inter) throws ClassNotFoundExcep * @throws ClassNotFoundException if superclasses or superinterfaces of this object can't be found */ public final boolean instanceOf(final JavaClass superclass) throws ClassNotFoundException { - if (this.equals(superclass)) { + if (equals(superclass)) { return true; } for (final JavaClass clazz : getSuperClasses()) { From ac9568b32644e22df5366b2dc1c73e37efbe9e25 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:39:42 -0400 Subject: [PATCH 097/114] Remove redundant keywords --- .../org/apache/bcel/verifier/structurals/LocalVariables.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java b/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java index 1b27bb6769..05c8e1515a 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java @@ -87,7 +87,7 @@ public Type get(final int slotIndex) { * @return a (correctly typed) clone of this object. */ public LocalVariables getClone() { - return (LocalVariables) this.clone(); + return (LocalVariables) clone(); } /** From a1de20027fd0d1b0bb79735cdf7a328c64192e7c Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:39:52 -0400 Subject: [PATCH 098/114] Remove redundant keywords --- src/main/java/org/apache/bcel/generic/ObjectType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/generic/ObjectType.java b/src/main/java/org/apache/bcel/generic/ObjectType.java index 95a4df3f4c..b1e93b3da8 100644 --- a/src/main/java/org/apache/bcel/generic/ObjectType.java +++ b/src/main/java/org/apache/bcel/generic/ObjectType.java @@ -146,7 +146,7 @@ public boolean referencesInterfaceExact() throws ClassNotFoundException { * @throws ClassNotFoundException if any of this class's superclasses can't be found */ public boolean subclassOf(final ObjectType superclass) throws ClassNotFoundException { - if (this.referencesInterfaceExact() || superclass.referencesInterfaceExact()) { + if (referencesInterfaceExact() || superclass.referencesInterfaceExact()) { return false; } return Repository.instanceOf(this.className, superclass.className); From e953d1c3543f5fb13a4ce3c74916e2977db71229 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:40:03 -0400 Subject: [PATCH 099/114] Remove redundant keywords --- .../org/apache/bcel/verifier/structurals/OperandStack.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java b/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java index c9250c4dbb..036297226e 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java @@ -48,7 +48,7 @@ public OperandStack(final int maxStack) { */ public OperandStack(final int maxStack, final ObjectType obj) { this.maxStack = maxStack; - this.push(obj); + push(obj); } /** @@ -89,7 +89,7 @@ public boolean equals(final Object o) { * @see #clone() */ public OperandStack getClone() { - return (OperandStack) this.clone(); + return (OperandStack) clone(); } /** From 44423b3b5710a7193947c614333060457630e0ee Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:40:10 -0400 Subject: [PATCH 100/114] Remove redundant keywords --- .../java/org/apache/bcel/verifier/statics/Pass2Verifier.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java b/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java index 6ea0d18d1a..83f287cb44 100644 --- a/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java +++ b/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java @@ -1444,7 +1444,7 @@ private void finalMethodsAreNotOverridden() { * Leave that to JustIce. */ public LocalVariablesInfo getLocalVariablesInfo(final int methodNr) { - if (this.verify() != VerificationResult.VR_OK) { + if (verify() != VerificationResult.VR_OK) { return null; // It's cached, don't worry. } if (methodNr < 0 || methodNr >= localVariablesInfos.length) { From 9365f4bf3fc33e3e86fd390e9eb6fc8ca6edb3ff Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:40:17 -0400 Subject: [PATCH 101/114] Remove redundant keywords --- .../org/apache/bcel/verifier/structurals/Pass3bVerifier.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java b/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java index 7e3413b585..c35b81f29c 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java @@ -276,14 +276,14 @@ private void circulationPump(final MethodGen m, final ControlFlowGraph cfg, fina final LocalVariables lvs = f.getLocals(); for (int i = 0; i < lvs.maxLocals(); i++) { if (lvs.get(i) instanceof UninitializedObjectType) { - this.addMessage("Warning: ReturnInstruction '" + ic + "' may leave method with an uninitialized object in the local variables array '" + addMessage("Warning: ReturnInstruction '" + ic + "' may leave method with an uninitialized object in the local variables array '" + lvs + "'."); } } final OperandStack os = f.getStack(); for (int i = 0; i < os.size(); i++) { if (os.peek(i) instanceof UninitializedObjectType) { - this.addMessage( + addMessage( "Warning: ReturnInstruction '" + ic + "' may leave method with an uninitialized object on the operand stack '" + os + "'."); } } From 328fd49c297b2865fc66e2d6647c92ee002aaa54 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:40:32 -0400 Subject: [PATCH 102/114] Remove redundant keywords --- .../java/org/apache/bcel/verifier/structurals/Subroutines.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java b/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java index 565c95362e..d79a9a0613 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java @@ -219,7 +219,7 @@ public int[] getRecursivelyAccessedLocalsIndices() { for (final int lv : lvs) { s.add(Integer.valueOf(lv)); } - getRecursivelyAccessedLocalsIndicesHelper(s, this.subSubs()); + getRecursivelyAccessedLocalsIndicesHelper(s, subSubs()); final int[] ret = new int[s.size()]; int j = -1; for (final Integer index : s) { From e06ce12499646dc31afdd3a87f0760494674edbc Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:40:51 -0400 Subject: [PATCH 103/114] Remove redundant keywords --- .../org/apache/bcel/generic/ReferenceType.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/bcel/generic/ReferenceType.java b/src/main/java/org/apache/bcel/generic/ReferenceType.java index 8fb838b2bd..4468dcb2ff 100644 --- a/src/main/java/org/apache/bcel/generic/ReferenceType.java +++ b/src/main/java/org/apache/bcel/generic/ReferenceType.java @@ -49,10 +49,10 @@ protected ReferenceType(final byte t, final String s) { */ @Deprecated public ReferenceType firstCommonSuperclass(final ReferenceType t) throws ClassNotFoundException { - if (this.equals(NULL)) { + if (equals(NULL)) { return t; } - if (t.equals(NULL) || this.equals(t)) { + if (t.equals(NULL) || equals(t)) { return this; /* * TODO: Above sounds a little arbitrary. On the other hand, there is no object referenced by {@link #NULL} so we can also @@ -80,10 +80,10 @@ public ReferenceType firstCommonSuperclass(final ReferenceType t) throws ClassNo * @throws ClassNotFoundException on failure to find superclasses of this type, or the type passed as a parameter */ public ReferenceType getFirstCommonSuperclass(final ReferenceType t) throws ClassNotFoundException { - if (this.equals(NULL)) { + if (equals(NULL)) { return t; } - if (t.equals(NULL) || this.equals(t)) { + if (t.equals(NULL) || equals(t)) { return this; /* * TODO: Above sounds a little arbitrary. On the other hand, there is no object referenced by {@link #NULL} so we can also @@ -154,7 +154,7 @@ public boolean isAssignmentCompatibleWith(final Type t) throws ClassNotFoundExce return false; } final ReferenceType T = (ReferenceType) t; - if (this.equals(NULL)) { + if (equals(NULL)) { return true; // This is not explicitly stated, but clear. Isn't it? } /* @@ -165,7 +165,7 @@ public boolean isAssignmentCompatibleWith(final Type t) throws ClassNotFoundExce * If T is a class type, then this must be the same class as T, or this must be a subclass of T; */ if (T instanceof ObjectType && ((ObjectType) T).referencesClassExact() - && (this.equals(T) || Repository.instanceOf(((ObjectType) this).getClassName(), ((ObjectType) T).getClassName()))) { + && (equals(T) || Repository.instanceOf(((ObjectType) this).getClassName(), ((ObjectType) T).getClassName()))) { return true; } /* @@ -190,7 +190,7 @@ public boolean isAssignmentCompatibleWith(final Type t) throws ClassNotFoundExce * If T is an interface type, then T must be the same interface as this or a superinterface of this (īŋŊ2.13.2). */ if (T instanceof ObjectType && ((ObjectType) T).referencesInterfaceExact() - && (this.equals(T) || Repository.implementationOf(((ObjectType) this).getClassName(), ((ObjectType) T).getClassName()))) { + && (equals(T) || Repository.implementationOf(((ObjectType) this).getClassName(), ((ObjectType) T).getClassName()))) { return true; } } @@ -249,7 +249,7 @@ public boolean isAssignmentCompatibleWith(final Type t) throws ClassNotFoundExce * found */ public boolean isCastableTo(final Type t) throws ClassNotFoundException { - if (this.equals(NULL)) { + if (equals(NULL)) { return t instanceof ReferenceType; // If this is ever changed in isAssignmentCompatible() } return isAssignmentCompatibleWith(t); From 6ffd5ef08c2f2c45cc48655f36998d92d1bcad44 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:41:01 -0400 Subject: [PATCH 104/114] Remove redundant keywords --- src/main/java/org/apache/bcel/generic/Type.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/bcel/generic/Type.java b/src/main/java/org/apache/bcel/generic/Type.java index 668f12cd40..058157a5ba 100644 --- a/src/main/java/org/apache/bcel/generic/Type.java +++ b/src/main/java/org/apache/bcel/generic/Type.java @@ -402,6 +402,6 @@ public Type normalizeForStackOrLocal() { */ @Override public String toString() { - return this.equals(NULL) || type >= Const.T_UNKNOWN ? signature : Utility.signatureToString(signature, false); + return equals(NULL) || type >= Const.T_UNKNOWN ? signature : Utility.signatureToString(signature, false); } } From 65bd198c10ff4caca259fe6e639ed91a8bf328c3 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:41:14 -0400 Subject: [PATCH 105/114] Remove redundant keywords --- .../java/org/apache/bcel/verifier/VerifierAppFrame.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/bcel/verifier/VerifierAppFrame.java b/src/main/java/org/apache/bcel/verifier/VerifierAppFrame.java index e8482cc2ab..e7a26db2f5 100644 --- a/src/main/java/org/apache/bcel/verifier/VerifierAppFrame.java +++ b/src/main/java/org/apache/bcel/verifier/VerifierAppFrame.java @@ -128,11 +128,11 @@ JList getClassNamesJList() { /** Initizalization of the components. */ private void jbInit() { // setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Ihr Symbol]"))); - contentPane = (JPanel) this.getContentPane(); + contentPane = (JPanel) getContentPane(); contentPane.setLayout(cardLayout1); - this.setJMenuBar(jMenuBar1); + setJMenuBar(jMenuBar1); this.setSize(new Dimension(708, 451)); - this.setTitle("JustIce"); + setTitle("JustIce"); jPanel1.setMinimumSize(new Dimension(100, 100)); jPanel1.setPreferredSize(new Dimension(100, 100)); jPanel1.setLayout(gridLayout1); From d93052b46aa2abe86d6ec73e02550166d98791a3 Mon Sep 17 00:00:00 2001 From: "Gary David Gregory (Code signing key)" Date: Tue, 9 Jul 2024 08:41:27 -0400 Subject: [PATCH 106/114] Remove redundant keywords --- .../org/apache/bcel/verifier/VerifyDialog.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/bcel/verifier/VerifyDialog.java b/src/main/java/org/apache/bcel/verifier/VerifyDialog.java index 5427bcc332..a276ec4dbc 100644 --- a/src/main/java/org/apache/bcel/verifier/VerifyDialog.java +++ b/src/main/java/org/apache/bcel/verifier/VerifyDialog.java @@ -50,16 +50,16 @@ final class IvjEventHandler implements ActionListener { @Override public void actionPerformed(final ActionEvent e) { - if (e.getSource() == VerifyDialog.this.getPass1Button()) { + if (e.getSource() == getPass1Button()) { connEtoC1(e); } - if (e.getSource() == VerifyDialog.this.getPass2Button()) { + if (e.getSource() == getPass2Button()) { connEtoC2(e); } - if (e.getSource() == VerifyDialog.this.getPass3Button()) { + if (e.getSource() == getPass3Button()) { connEtoC3(e); } - if (e.getSource() == VerifyDialog.this.getFlushButton()) { + if (e.getSource() == getFlushButton()) { connEtoC4(e); } } @@ -196,7 +196,7 @@ private void connEtoC1(final ActionEvent arg1) { try { // user code begin {1} // user code end - this.pass1Button_ActionPerformed(arg1); + pass1Button_ActionPerformed(arg1); // user code begin {2} // user code end } catch (final Throwable ivjExc) { @@ -211,7 +211,7 @@ private void connEtoC2(final ActionEvent arg1) { try { // user code begin {1} // user code end - this.pass2Button_ActionPerformed(arg1); + pass2Button_ActionPerformed(arg1); // user code begin {2} // user code end } catch (final Throwable ivjExc) { @@ -226,7 +226,7 @@ private void connEtoC3(final ActionEvent arg1) { try { // user code begin {1} // user code end - this.pass4Button_ActionPerformed(arg1); + pass4Button_ActionPerformed(arg1); // user code begin {2} // user code end } catch (final Throwable ivjExc) { @@ -241,7 +241,7 @@ private void connEtoC4(final ActionEvent arg1) { try { // user code begin {1} // user code end - this.flushButton_ActionPerformed(arg1); + flushButton_ActionPerformed(arg1); // user code begin {2} // user code end } catch (final Throwable ivjExc) { From fe3651d5cfd4796cec01c8acef88c50ad2bac290 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:19:55 -0400 Subject: [PATCH 107/114] Bump github/codeql-action from 3.25.11 to 3.25.12 (#333) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.11 to 3.25.12. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/b611370bb5703a7efb587f9d136a52ea24c5c38c...4fa2a7953630fd2f3fb380f21be14ede0169dd4f) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4f743b02fe..19af8b6942 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + uses: github/codeql-action/init@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + uses: github/codeql-action/autobuild@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + uses: github/codeql-action/analyze@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 93717531c6..1ba6b765bb 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # 3.25.11 + uses: github/codeql-action/upload-sarif@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # 3.25.12 with: sarif_file: results.sarif From 10f5191069d88e28d5a08652e315c15bdfd65059 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Jul 2024 21:52:33 -0400 Subject: [PATCH 108/114] Bump org.assertj:assertj-core from 3.26.0 to 3.26.3 (#332) Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.26.0 to 3.26.3. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.26.0...assertj-build-3.26.3) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b26bf7ec56..b1ea1a610c 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ BCEL 12314220 4.11.0 - 3.26.0 + 3.26.3 5.14.0 false From 9818c8929c9c3e85f85e1518d4d74bed9d245e50 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 12 Jul 2024 21:53:09 -0400 Subject: [PATCH 109/114] Bump org.assertj:assertj-core from 3.26.0 to 3.26.3 #332 --- src/changes/changes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 1b47e750cd..a2306bc3ce 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -76,7 +76,7 @@ The type attribute can be add,update,fix,remove. Add accessors to model and unit tests, Javadoc #183. - Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.0 #322. + Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.3 #322, #332. Bump tests from org.jetbrains.kotlin:kotlin-stdlib 1.9.23 to 2.0.0 #309, #318. Bump tests from org.apache.commons:commons-collections4 4.4 to 4.5.0-M2. Bump org.apache.commons:commons-parent from 69 to 71. From e9aa06834d3b654713df056a84d4ef008227f7b9 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 13 Jul 2024 11:00:16 -0400 Subject: [PATCH 110/114] Add Const.MAJOR_22 Add Const.MINOR_22 --- src/changes/changes.xml | 2 ++ src/main/java/org/apache/bcel/Const.java | 16 +++++++++ src/test/java/org/apache/bcel/ConstTest.java | 34 ++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/test/java/org/apache/bcel/ConstTest.java diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a2306bc3ce..4bc182ee05 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -75,6 +75,8 @@ The type attribute can be add,update,fix,remove. Deprecate TransitiveHull.INGORED in favor of TransitiveHull.getIgnored(). Add accessors to model and unit tests, Javadoc #183. + Add Const.MAJOR_22. + Add Const.MINOR_22. Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.3 #322, #332. Bump tests from org.jetbrains.kotlin:kotlin-stdlib 1.9.23 to 2.0.0 #309, #318. diff --git a/src/main/java/org/apache/bcel/Const.java b/src/main/java/org/apache/bcel/Const.java index fd554493fd..80614c579c 100644 --- a/src/main/java/org/apache/bcel/Const.java +++ b/src/main/java/org/apache/bcel/Const.java @@ -292,6 +292,14 @@ public final class Const { */ public static final short MINOR_21 = 0; + /** + * Minor version number of class files for Java 22: {@value}. + * + * @see #MAJOR_22 + * @since 6.10.0 + */ + public static final short MINOR_22 = 0; + /** * Major version number of class files for Java 14: {@value}. * @@ -356,6 +364,14 @@ public final class Const { */ public static final short MAJOR_21 = 65; + /** + * Major version number of class files for Java 22: {@value}. + * + * @see #MINOR_22 + * @since 6.10.0 + */ + public static final short MAJOR_22 = 66; + /** * Default major version number. Class file is for Java 1.1: {@value}. * diff --git a/src/test/java/org/apache/bcel/ConstTest.java b/src/test/java/org/apache/bcel/ConstTest.java new file mode 100644 index 0000000000..feb6307ca5 --- /dev/null +++ b/src/test/java/org/apache/bcel/ConstTest.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.bcel; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +/** + * Tests {@link Const}. + */ +public class ConstTest { + + @Test + public void testJava22() throws Exception { + assertEquals(66, Const.MAJOR_22); + assertEquals(0, Const.MINOR_22); + } +} From 8f87b819d3b00831b1e62ac2659dfeb7bc9a0897 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 13 Jul 2024 11:06:18 -0400 Subject: [PATCH 111/114] Add Const.MAJOR_23 Add Const.MINOR_23 --- src/changes/changes.xml | 2 ++ src/main/java/org/apache/bcel/Const.java | 16 ++++++++++++++++ src/test/java/org/apache/bcel/ConstTest.java | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 4bc182ee05..2f5b3c7caf 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -77,6 +77,8 @@ The type attribute can be add,update,fix,remove. Add accessors to model and unit tests, Javadoc #183. Add Const.MAJOR_22. Add Const.MINOR_22. + Add Const.MAJOR_23. + Add Const.MINOR_23. Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.3 #322, #332. Bump tests from org.jetbrains.kotlin:kotlin-stdlib 1.9.23 to 2.0.0 #309, #318. diff --git a/src/main/java/org/apache/bcel/Const.java b/src/main/java/org/apache/bcel/Const.java index 80614c579c..9486c0faf4 100644 --- a/src/main/java/org/apache/bcel/Const.java +++ b/src/main/java/org/apache/bcel/Const.java @@ -300,6 +300,14 @@ public final class Const { */ public static final short MINOR_22 = 0; + /** + * Minor version number of class files for Java 22: {@value}. + * + * @see #MAJOR_23 + * @since 6.10.0 + */ + public static final short MINOR_23 = 0; + /** * Major version number of class files for Java 14: {@value}. * @@ -372,6 +380,14 @@ public final class Const { */ public static final short MAJOR_22 = 66; + /** + * Major version number of class files for Java 23: {@value}. + * + * @see #MINOR_23 + * @since 6.10.0 + */ + public static final short MAJOR_23 = 67; + /** * Default major version number. Class file is for Java 1.1: {@value}. * diff --git a/src/test/java/org/apache/bcel/ConstTest.java b/src/test/java/org/apache/bcel/ConstTest.java index feb6307ca5..f1cb5b8a79 100644 --- a/src/test/java/org/apache/bcel/ConstTest.java +++ b/src/test/java/org/apache/bcel/ConstTest.java @@ -31,4 +31,10 @@ public void testJava22() throws Exception { assertEquals(66, Const.MAJOR_22); assertEquals(0, Const.MINOR_22); } + + @Test + public void testJava23() throws Exception { + assertEquals(67, Const.MAJOR_23); + assertEquals(0, Const.MINOR_23); + } } From 2d95820fa2a34f6a38edfb9f838195c68b39f6c0 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 13 Jul 2024 11:07:40 -0400 Subject: [PATCH 112/114] Add Const.MAJOR_24 Add Const.MINOR_24 --- src/changes/changes.xml | 2 ++ src/main/java/org/apache/bcel/Const.java | 18 +++++++++++++++++- src/test/java/org/apache/bcel/ConstTest.java | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 2f5b3c7caf..bdde47c62c 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -79,6 +79,8 @@ The type attribute can be add,update,fix,remove. Add Const.MINOR_22. Add Const.MAJOR_23. Add Const.MINOR_23. + Add Const.MAJOR_24. + Add Const.MINOR_24. Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.3 #322, #332. Bump tests from org.jetbrains.kotlin:kotlin-stdlib 1.9.23 to 2.0.0 #309, #318. diff --git a/src/main/java/org/apache/bcel/Const.java b/src/main/java/org/apache/bcel/Const.java index 9486c0faf4..de00efa9ea 100644 --- a/src/main/java/org/apache/bcel/Const.java +++ b/src/main/java/org/apache/bcel/Const.java @@ -301,13 +301,21 @@ public final class Const { public static final short MINOR_22 = 0; /** - * Minor version number of class files for Java 22: {@value}. + * Minor version number of class files for Java 23: {@value}. * * @see #MAJOR_23 * @since 6.10.0 */ public static final short MINOR_23 = 0; + /** + * Minor version number of class files for Java 24: {@value}. + * + * @see #MAJOR_24 + * @since 6.10.0 + */ + public static final short MINOR_24 = 0; + /** * Major version number of class files for Java 14: {@value}. * @@ -388,6 +396,14 @@ public final class Const { */ public static final short MAJOR_23 = 67; + /** + * Major version number of class files for Java 24: {@value}. + * + * @see #MINOR_24 + * @since 6.10.0 + */ + public static final short MAJOR_24 = 68; + /** * Default major version number. Class file is for Java 1.1: {@value}. * diff --git a/src/test/java/org/apache/bcel/ConstTest.java b/src/test/java/org/apache/bcel/ConstTest.java index f1cb5b8a79..94310df8d1 100644 --- a/src/test/java/org/apache/bcel/ConstTest.java +++ b/src/test/java/org/apache/bcel/ConstTest.java @@ -37,4 +37,10 @@ public void testJava23() throws Exception { assertEquals(67, Const.MAJOR_23); assertEquals(0, Const.MINOR_23); } + + @Test + public void testJava24() throws Exception { + assertEquals(68, Const.MAJOR_24); + assertEquals(0, Const.MINOR_24); + } } From a7333c089bd27d87fc472eebb6ee9cbb58218f47 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 13 Jul 2024 18:11:07 +0000 Subject: [PATCH 113/114] Prepare for the next release candidate --- CONTRIBUTING.md | 9 ++--- README.md | 8 ++-- RELEASE-NOTES.txt | 72 +++++++++++++++++++++++++++++++++ src/changes/changes.xml | 2 +- src/site/xdoc/download_bcel.xml | 26 ++++++------ 5 files changed, 95 insertions(+), 22 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd33383389..0f99265e37 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,9 +41,8 @@ Contributing to Apache Commons BCEL ====================== -You have found a bug or you have an idea for a cool new feature? Contributing code is a great way to give something back to -the open source community. Before you dig right into the code there are a few guidelines that we need contributors to -follow so that we can have a chance of keeping on top of things. +Have you found a bug or have an idea for a cool new feature? Contributing code is a great way to give something back to the open-source community. +Before you dig right into the code, we need contributors to follow a few guidelines to have a chance of keeping on top of things. Getting Started --------------- @@ -62,7 +61,7 @@ Making Changes + Create a _topic branch_ for your isolated work. * Usually you should base your branch on the `master` branch. - * A good topic branch name can be the JIRA bug id plus a keyword, e.g. `BCEL-123-InputStream`. + * A good topic branch name can be the JIRA bug ID plus a keyword, e.g. `BCEL-123-InputStream`. * If you have submitted multiple JIRA issues, try to maintain separate branches and pull requests. + Make commits of logical units. * Make sure your commit messages are meaningful and in the proper format. Your commit message should contain the key of the JIRA issue. @@ -72,7 +71,7 @@ Making Changes + Create minimal diffs - disable _On Save_ actions like _Reformat Source Code_ or _Organize Imports_. If you feel the source code should be reformatted create a separate PR for this change first. + Check for unnecessary whitespace with `git diff` -- check before committing. + Make sure you have added the necessary tests for your changes, typically in `src/test/java`. -+ Run all the tests with `mvn clean verify` to assure nothing else was accidentally broken. ++ Run all the tests with `mvn clean verify` to ensure nothing else was accidentally broken. Making Trivial Changes ---------------------- diff --git a/README.md b/README.md index 9c4aa0a87a..68810a28ce 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Apache Commons BCEL [![Java CI](https://github.com/apache/commons-bcel/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-bcel/actions/workflows/maven.yml) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/badge.svg?gav=true)](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/?gav=true) -[![Javadocs](https://javadoc.io/badge/org.apache.bcel/bcel/6.9.0.svg)](https://javadoc.io/doc/org.apache.bcel/bcel/6.9.0) +[![Javadocs](https://javadoc.io/badge/org.apache.bcel/bcel/6.10.0.svg)](https://javadoc.io/doc/org.apache.bcel/bcel/6.10.0) [![CodeQL](https://github.com/apache/commons-bcel/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/apache/commons-bcel/actions/workflows/codeql-analysis.yml) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/apache/commons-bcel/badge)](https://api.securityscorecards.dev/projects/github.com/apache/commons-bcel) @@ -68,7 +68,7 @@ Alternatively, you can pull it from the central Maven repositories: org.apache.bcel bcel - 6.9.0 + 6.10.0 ``` @@ -88,7 +88,9 @@ There are some guidelines which will make applying PRs easier for us: + No tabs! Please use spaces for indentation. + Respect the existing code style for each file. + Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change. -+ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running ```mvn```. ++ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running `mvn`. ++ Before you pushing a PR, run `mvn` (by itself), this runs the default goal, which contains all build checks. ++ To see the code coverage report, regardless of coverage failures, run `mvn clean site -Dcommons.jacoco.haltOnFailure=false` If you plan to contribute on a regular basis, please consider filing a [contributor license agreement](https://www.apache.org/licenses/#clas). You can learn more about contributing via GitHub in our [contribution guidelines](CONTRIBUTING.md). diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index d9b16ea375..10c9331991 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,3 +1,75 @@ +Apache Commons BCEL Version 6.10.0 +RELEASE NOTES + + +Introduction +------------ +The Apache Commons BCEL team is pleased to announce the release of +Apache Commons BCEL 6.10.0. + +The Byte Code Engineering Library (BCEL) is intended to give users a convenient +way to analyze, create, and manipulate compiled .class files. Classes are +represented by objects containing all the symbolic information of the given +class: methods, fields, and byte code instructions. + +Maintenance and bug fix release. Requires a minimum of Java 8. + +Changes +------- +* Fix PMD UnnecessaryFullyQualifiedName. Thanks to Gary Gregory. +* Fix PMD EmptyCatchBlock by allowing commented blocks. Thanks to Gary Gregory. +* Fix PMD EmptyControlStatement by allowing commented blocks. Thanks to Gary Gregory. +* Fix SpotBugs RV_RETURN_VALUE_IGNORED_BAD_PRACTICE in JasminVisitor. Thanks to Gary Gregory. +* SpotBugs checks should ignore code generated by JavaCC. Thanks to Gary Gregory. +* Fix SpotBugs URF_UNREAD_FIELD in ClassDumper. Thanks to Gary Gregory. +* Fix SpotBugs DM_DEFAULT_ENCODING in JasminVisitor. Thanks to Gary Gregory. +* Fix SpotBugs RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE in ASTFunAppl. Thanks to Gary Gregory. +* Fix SpotBugs RV_ABSOLUTE_VALUE_OF_HASHCODE in Mini.Environment. Thanks to Gary Gregory. +* Fix SpotBugs DM_DEFAULT_ENCODING in Mini.MiniC. Thanks to Gary Gregory. +* Fix SpotBugs WMI_WRONG_MAP_ITERATOR in Package.go(String[]). Thanks to Gary Gregory. +* Deprecate TransitiveHull.INGORED in favor of TransitiveHull.getIgnored(). Thanks to Gary Gregory. +* Add accessors to model and unit tests, Javadoc #183. Thanks to nbauma109, Gary Gregory, Mark Roberts. +* Add Const.MAJOR_22. Thanks to Gary Gregory. +* Add Const.MINOR_22. Thanks to Gary Gregory. +* Add Const.MAJOR_23. Thanks to Gary Gregory. +* Add Const.MINOR_23. Thanks to Gary Gregory. +* Add Const.MAJOR_24. Thanks to Gary Gregory. +* Add Const.MINOR_24. Thanks to Gary Gregory. +* Bump tests from org.assertj:assertj-core 3.25.3 to 3.26.3 #322, #332. Thanks to Dependabot. +* Bump tests from org.jetbrains.kotlin:kotlin-stdlib 1.9.23 to 2.0.0 #309, #318. Thanks to Dependabot. +* Bump tests from org.apache.commons:commons-collections4 4.4 to 4.5.0-M2. Thanks to Gary Gregory. +* Bump org.apache.commons:commons-parent from 69 to 71. Thanks to Gary Gregory. +* Bump org.codehaus.mojo:taglist-maven-plugin from 3.0.0 to 3.1.0 #331. Thanks to Gary Gregory. + + +Historical list of changes: https://commons.apache.org/proper/commons-bcel/changes-report.html + +For complete information on Apache Commons BCEL, including instructions on how to submit bug reports, +patches, or suggestions for improvement, see the Apache Commons BCEL website: + +https://commons.apache.org/proper/commons-bcel + +Download it from https://commons.apache.org/proper/commons-bcel/download_bcel.cgi + +Have fun! +-Apache Commons BCEL team + +Feedback +-------- +Open source works best when you give feedback: + + https://commons.apache.org/bcel + +Please direct all bug reports to JIRA: + + https://issues.apache.org/jira/browse/BCEL + +Or subscribe to the commons-user mailing list + +The Apache Commons Team + +----------------------------------------------------------------------------- + Apache Commons BCEL Version 6.9.0 RELEASE NOTES diff --git a/src/changes/changes.xml b/src/changes/changes.xml index bdde47c62c..4323a93cca 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -59,7 +59,7 @@ The type attribute can be add,update,fix,remove. Defining changes.version allows one to create the RN without first removing the SNAPSHOT suffix. --> - + Fix PMD UnnecessaryFullyQualifiedName. Fix PMD EmptyCatchBlock by allowing commented blocks. diff --git a/src/site/xdoc/download_bcel.xml b/src/site/xdoc/download_bcel.xml index 1aee8987df..e26048f0f6 100644 --- a/src/site/xdoc/download_bcel.xml +++ b/src/site/xdoc/download_bcel.xml @@ -113,32 +113,32 @@ limitations under the License.

-
+
- - - + + + - - - + + +
bcel-6.9.0-bin.tar.gzsha512pgpbcel-6.10.0-bin.tar.gzsha512pgp
bcel-6.9.0-bin.zipsha512pgpbcel-6.10.0-bin.zipsha512pgp
- - - + + + - - - + + +
bcel-6.9.0-src.tar.gzsha512pgpbcel-6.10.0-src.tar.gzsha512pgp
bcel-6.9.0-src.zipsha512pgpbcel-6.10.0-src.zipsha512pgp
From 907c61da34258b8ab70081056443818312e404f6 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 13 Jul 2024 18:18:41 +0000 Subject: [PATCH 114/114] Prepare for the next release candidate --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b1ea1a610c..13e53d5ec4 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ org.apache.bcel bcel jar - 6.10.0-SNAPSHOT + 6.10.0 Apache Commons BCEL Apache Commons Bytecode Engineering Library @@ -43,7 +43,7 @@ UTF-8 UTF-8 - 2024-04-27T12:58:11Z + 2024-07-13T18:11:44Z 1.8 1.8 bcel