From 0ba07889a1cf464629875a8fc43ba978f23ba4ef Mon Sep 17 00:00:00 2001
From: Mark Roberts
Date: Wed, 7 Feb 2024 09:10:57 -0800
Subject: [PATCH 1/9] update from codespecs/commons-bcel for 6.8.1
---
.github/workflows/maven.yml | 6 +-
CONTRIBUTING.md | 5 +-
NOTICE.txt | 2 +-
README-codespecs.txt | 6 +-
README.md | 89 +-
RELEASE-NOTES.txt | 170 +++-
docs/verifier/JustIce.lyx | 2 +-
pom.xml | 300 ++++---
src/changes/changes.xml | 89 +-
src/changes/release-notes.vm | 6 +-
src/conf/checkstyle.xml | 40 +-
src/conf/spotbugs-exclude-filter.xml | 77 ++
src/examples/ClassDumper.java | 6 +-
src/examples/JasminVisitor.java | 2 +-
src/examples/Mini/ASCII_CharStream.java | 70 +-
src/examples/Mini/ASTFunDecl.java | 4 +-
src/examples/Mini/Environment.java | 4 +-
src/examples/Mini/MiniC.java | 8 +-
src/examples/Mini/MiniParser.java | 8 +-
src/examples/Mini/SimpleNode.java | 2 +-
src/examples/ProxyCreator.java | 6 +-
src/examples/TransitiveHull.java | 2 +-
src/main/java/org/apache/bcel/Const.java | 771 ++++++++++--------
.../apache/bcel/classfile/AccessFlags.java | 227 +++++-
.../bcel/classfile/AnnotationEntry.java | 4 +-
.../org/apache/bcel/classfile/Attribute.java | 2 +-
.../bcel/classfile/BootstrapMethod.java | 2 +-
.../bcel/classfile/BootstrapMethods.java | 2 +-
.../bcel/classfile/ClassFormatException.java | 10 +-
.../apache/bcel/classfile/ClassParser.java | 6 +-
.../java/org/apache/bcel/classfile/Code.java | 14 +
.../apache/bcel/classfile/CodeException.java | 4 +-
.../org/apache/bcel/classfile/Constant.java | 23 +-
.../apache/bcel/classfile/ConstantObject.java | 7 +-
.../apache/bcel/classfile/ConstantPool.java | 19 +-
.../apache/bcel/classfile/ConstantUtf8.java | 17 +-
.../apache/bcel/classfile/ConstantValue.java | 2 +-
.../org/apache/bcel/classfile/Deprecated.java | 2 +-
.../bcel/classfile/DescendingVisitor.java | 14 +
.../apache/bcel/classfile/EmptyVisitor.java | 9 +
.../apache/bcel/classfile/ExceptionTable.java | 2 +-
.../java/org/apache/bcel/classfile/Field.java | 31 +-
.../apache/bcel/classfile/FieldOrMethod.java | 8 +-
.../org/apache/bcel/classfile/InnerClass.java | 2 +-
.../apache/bcel/classfile/InnerClasses.java | 2 +-
.../InvalidMethodSignatureException.java | 49 ++
.../org/apache/bcel/classfile/JavaClass.java | 78 +-
.../org/apache/bcel/classfile/LineNumber.java | 4 +-
.../bcel/classfile/LineNumberTable.java | 2 +-
.../bcel/classfile/LocalVariableTable.java | 2 +-
.../org/apache/bcel/classfile/Method.java | 27 +-
.../bcel/classfile/MethodParameter.java | 12 +-
.../org/apache/bcel/classfile/Module.java | 2 +-
.../apache/bcel/classfile/ModuleExports.java | 2 +-
.../bcel/classfile/ModuleMainClass.java | 2 +-
.../apache/bcel/classfile/ModuleOpens.java | 2 +-
.../apache/bcel/classfile/ModulePackages.java | 2 +-
.../apache/bcel/classfile/ModuleProvides.java | 2 +-
.../apache/bcel/classfile/ModuleRequires.java | 2 +-
.../apache/bcel/classfile/NestMembers.java | 2 +-
.../java/org/apache/bcel/classfile/Node.java | 2 +-
.../org/apache/bcel/classfile/PMGClass.java | 2 +-
.../classfile/ParameterAnnotationEntry.java | 2 +-
.../org/apache/bcel/classfile/Signature.java | 2 +-
.../bcel/classfile/SimpleElementValue.java | 20 +-
.../org/apache/bcel/classfile/SourceFile.java | 2 +-
.../org/apache/bcel/classfile/StackMap.java | 2 +-
.../apache/bcel/classfile/StackMapEntry.java | 12 +-
.../apache/bcel/classfile/StackMapType.java | 29 +-
.../org/apache/bcel/classfile/Synthetic.java | 2 +-
.../org/apache/bcel/classfile/Utility.java | 30 +-
.../org/apache/bcel/classfile/Visitor.java | 9 +
.../apache/bcel/classfile/package-info.java | 21 +
.../org/apache/bcel/generic/ARRAYLENGTH.java | 2 +-
.../java/org/apache/bcel/generic/ATHROW.java | 3 +-
.../bcel/generic/AnnotationEntryGen.java | 4 +-
.../org/apache/bcel/generic/ArrayType.java | 4 +-
.../org/apache/bcel/generic/BranchHandle.java | 2 +-
.../bcel/generic/BranchInstruction.java | 2 +-
.../apache/bcel/generic/CPInstruction.java | 2 +-
.../org/apache/bcel/generic/ClassGen.java | 27 +-
.../apache/bcel/generic/CodeExceptionGen.java | 10 +-
.../apache/bcel/generic/ConstantPoolGen.java | 7 +-
.../apache/bcel/generic/ExceptionThrower.java | 2 +-
.../org/apache/bcel/generic/FieldGen.java | 36 +-
.../bcel/generic/FieldGenOrMethodGen.java | 2 +-
.../apache/bcel/generic/FieldOrMethod.java | 3 +
.../apache/bcel/generic/INVOKEDYNAMIC.java | 4 +-
.../apache/bcel/generic/InstructionConst.java | 2 +-
.../bcel/generic/InstructionConstants.java | 4 +-
.../bcel/generic/InstructionFactory.java | 20 +-
.../bcel/generic/InstructionHandle.java | 9 +-
.../apache/bcel/generic/InstructionList.java | 12 +-
.../java/org/apache/bcel/generic/LCMP.java | 1 -
.../java/org/apache/bcel/generic/LDC.java | 9 +-
.../apache/bcel/generic/LineNumberGen.java | 4 +-
.../apache/bcel/generic/LocalVariableGen.java | 2 +-
.../generic/LocalVariableInstruction.java | 2 +-
.../org/apache/bcel/generic/MethodGen.java | 29 +-
.../org/apache/bcel/generic/ObjectType.java | 4 +-
.../java/org/apache/bcel/generic/RET.java | 2 +-
.../apache/bcel/generic/ReferenceType.java | 8 +-
.../java/org/apache/bcel/generic/SWITCH.java | 2 +-
.../java/org/apache/bcel/generic/Select.java | 6 +-
.../bcel/generic/SimpleElementValueGen.java | 6 +-
.../java/org/apache/bcel/generic/Type.java | 52 +-
.../apache/bcel/generic/TypedInstruction.java | 2 +-
.../org/apache/bcel/generic/package-info.java | 22 +
.../java/org/apache/bcel/package-info.java | 22 +
.../org/apache/bcel/util/BCELComparator.java | 23 +-
.../org/apache/bcel/util/BCELFactory.java | 2 +-
.../java/org/apache/bcel/util/BCELifier.java | 86 ++
.../java/org/apache/bcel/util/Class2HTML.java | 2 +-
.../java/org/apache/bcel/util/ClassPath.java | 14 +-
.../org/apache/bcel/util/ClassVector.java | 8 +-
.../java/org/apache/bcel/util/CodeHTML.java | 2 +-
.../apache/bcel/util/InstructionFinder.java | 2 +-
.../org/apache/bcel/util/JavaWrapper.java | 2 +-
.../org/apache/bcel/util/package-info.java | 28 +
.../bcel/verifier/GraphicalVerifier.java | 2 +-
.../bcel/verifier/VerifierAppFrame.java | 18 +-
.../apache/bcel/verifier/VerifyDialog.java | 9 +-
.../bcel/verifier/exc/package-info.java | 25 +
.../apache/bcel/verifier/package-info.java | 25 +
.../bcel/verifier/statics/Pass2Verifier.java | 18 +-
.../bcel/verifier/statics/Pass3aVerifier.java | 93 +--
.../bcel/verifier/statics/package-info.java | 26 +
.../structurals/ControlFlowGraph.java | 9 +-
.../structurals/ExceptionHandler.java | 2 +-
.../structurals/ExceptionHandlers.java | 2 +-
.../structurals/ExecutionVisitor.java | 6 +-
.../verifier/structurals/GenericArray.java | 2 +-
.../structurals/InstConstraintVisitor.java | 104 +--
.../structurals/InstructionContext.java | 4 +-
.../verifier/structurals/Subroutines.java | 6 +-
.../verifier/structurals/package-info.java | 26 +
src/site/xdoc/download_bcel.xml | 26 +-
src/site/xdoc/index.xml | 11 +-
src/site/xdoc/mail-lists.xml | 38 +-
.../org/apache/bcel/AbstractTestCase.java | 71 +-
.../org/apache/bcel/AnnotationEntryTest.java | 60 ++
.../java/org/apache/bcel/BCELBenchmark.java | 58 +-
.../apache/bcel/CounterVisitorTestCase.java | 5 +
.../EnclosingMethodAttributeTestCase.java | 1 +
.../bcel/LocalVariableTypeTableTestCase.java | 6 +-
.../java/org/apache/bcel/OssFuzzTestCase.java | 23 +-
.../ConstantPoolModuleToStringTestCase.java | 12 +-
.../bcel/classfile/ConstantPoolTestCase.java | 31 +-
.../apache/bcel/classfile/ConstantTest.java | 38 +
.../org/apache/bcel/classfile/FieldTest.java | 38 +
.../InvalidMethodSigantureTestCase.java | 83 ++
.../bcel/classfile/JDKClassDumpTestCase.java | 3 +-
.../bcel/classfile/SignatureTestCase.java | 83 ++
.../apache/bcel/classfile/StackMapTest.java | 36 +
.../apache/bcel/classfile/TestJira368.java | 65 ++
.../bcel/classfile/UtilityTestCase.java | 83 +-
.../apache/bcel/data/AnonymousClassTest.java | 2 +-
.../bcel/data/AttributeTestClassEM01.java | 2 +-
.../org/apache/bcel/data/LargeMethod.java | 2 +-
src/test/java/org/apache/bcel/data/SWAP.java | 37 +
.../bcel/generic/BREAKPOINTTestCase.java | 2 +-
.../apache/bcel/generic/BinaryOpCreator.java | 24 +-
.../org/apache/bcel/generic/ClassGenTest.java | 38 +
.../org/apache/bcel/generic/D2FTestCase.java | 2 +-
.../org/apache/bcel/generic/D2ITestCase.java | 2 +-
.../org/apache/bcel/generic/D2LTestCase.java | 2 +-
.../org/apache/bcel/generic/DADDTestCase.java | 2 +-
.../org/apache/bcel/generic/DDIVTestCase.java | 2 +-
.../org/apache/bcel/generic/DMULTestCase.java | 2 +-
.../org/apache/bcel/generic/DNEGTestCase.java | 2 +-
.../org/apache/bcel/generic/DREMTestCase.java | 2 +-
.../org/apache/bcel/generic/DSUBTestCase.java | 2 +-
.../bcel/generic/EmptyVisitorTestCase.java | 7 +-
.../org/apache/bcel/generic/F2DTestCase.java | 2 +-
.../org/apache/bcel/generic/F2ITestCase.java | 2 +-
.../org/apache/bcel/generic/F2LTestCase.java | 2 +-
.../org/apache/bcel/generic/FADDTestCase.java | 2 +-
.../org/apache/bcel/generic/FDIVTestCase.java | 2 +-
.../org/apache/bcel/generic/FMULTestCase.java | 2 +-
.../org/apache/bcel/generic/FNEGTestCase.java | 2 +-
.../org/apache/bcel/generic/FREMTestCase.java | 2 +-
.../org/apache/bcel/generic/FSUBTestCase.java | 2 +-
.../org/apache/bcel/generic/FieldGenTest.java | 44 +
.../apache/bcel/generic/GETFIELDTestCase.java | 2 +-
.../GeneratingAnnotatedClassesTestCase.java | 10 +-
.../org/apache/bcel/generic/I2BTestCase.java | 2 +-
.../org/apache/bcel/generic/I2CTestCase.java | 2 +-
.../org/apache/bcel/generic/I2DTestCase.java | 2 +-
.../org/apache/bcel/generic/I2FTestCase.java | 2 +-
.../org/apache/bcel/generic/I2LTestCase.java | 2 +-
.../org/apache/bcel/generic/I2STestCase.java | 2 +-
.../org/apache/bcel/generic/IADDTestCase.java | 2 +-
.../org/apache/bcel/generic/IANDTestCase.java | 2 +-
.../org/apache/bcel/generic/IDIVTestCase.java | 2 +-
.../apache/bcel/generic/IMPDEP1TestCase.java | 2 +-
.../apache/bcel/generic/IMPDEP2TestCase.java | 2 +-
.../org/apache/bcel/generic/IMULTestCase.java | 2 +-
.../org/apache/bcel/generic/INEGTestCase.java | 2 +-
.../org/apache/bcel/generic/IORTestCase.java | 2 +-
.../org/apache/bcel/generic/IREMTestCase.java | 2 +-
.../org/apache/bcel/generic/ISHLTestCase.java | 2 +-
.../org/apache/bcel/generic/ISHRTestCase.java | 2 +-
.../org/apache/bcel/generic/ISUBTestCase.java | 2 +-
.../org/apache/bcel/generic/IXORTestCase.java | 2 +-
.../generic/InstructionFactoryTestCase.java | 100 +++
.../org/apache/bcel/generic/JavaHome.java | 23 +-
.../bcel/generic/JdkGenericDumpTestCase.java | 2 +-
.../bcel/generic/JiraBcel362TestCase.java | 2 +
.../org/apache/bcel/generic/L2DTestCase.java | 2 +-
.../org/apache/bcel/generic/L2FTestCase.java | 2 +-
.../org/apache/bcel/generic/L2ITestCase.java | 2 +-
.../org/apache/bcel/generic/LADDTestCase.java | 2 +-
.../org/apache/bcel/generic/LANDTestCase.java | 2 +-
.../org/apache/bcel/generic/LCMPTestCase.java | 2 +-
.../org/apache/bcel/generic/LDIVTestCase.java | 2 +-
.../org/apache/bcel/generic/LMULTestCase.java | 2 +-
.../org/apache/bcel/generic/LNEGTestCase.java | 2 +-
.../org/apache/bcel/generic/LORTestCase.java | 2 +-
.../org/apache/bcel/generic/LREMTestCase.java | 2 +-
.../org/apache/bcel/generic/LSHLTestCase.java | 2 +-
.../org/apache/bcel/generic/LSHRTestCase.java | 2 +-
.../org/apache/bcel/generic/LSUBTestCase.java | 2 +-
.../org/apache/bcel/generic/LXORTestCase.java | 2 +-
.../org/apache/bcel/generic/LargeJump.java | 2 +-
.../apache/bcel/generic/PUTFIELDTestCase.java | 2 +-
.../bcel/generic/PUTSTATICTestCase.java | 2 +-
.../org/apache/bcel/generic/TypeTestCase.java | 67 ++
.../apache/bcel/util/BCELifierTestCase.java | 15 +-
.../apache/bcel/util/Class2HTMLTestCase.java | 16 +-
.../bcel/verifier/JiraBcel369TestCase.java | 121 +++
.../bcel/verifier/JiraBcel369TestFixture.java | 35 +
.../bcel/verifier/JiraBcel370TestCase.java | 79 ++
.../bcel/verifier/VerifierMainTestCase.java | 93 +++
.../bcel/verifier/VerifierTestCase.java | 34 +-
.../bcel/verifier/VerifierThrowTestCase.java | 31 +
.../verifier/VerifyBadClassesTestCase.java | 6 +-
.../input/FieldVerifierChildClass.java | 49 ++
.../input/FieldVerifierSuperClass.java | 37 +
.../input/StaticFieldVerifierChildClass.java | 50 ++
.../input/StaticFieldVerifierSuperClass.java | 38 +
.../statics/Pass3aVerifierTestCase.java | 135 +++
.../InstConstraintVisitorTestCase.java | 52 ++
.../bcel/verifier/tests/JvmOpCodes.java | 172 ++++
.../verifier/tests/TestThrow01Creator.java | 47 ++
.../apache/bcel/visitors/CountingVisitor.java | 11 +
src/test/resources/StackMapExample.class | Bin 0 -> 790 bytes
src/test/resources/StackMapExample.java | 18 +
src/test/resources/StackMapExample2.class | Bin 0 -> 673 bytes
src/test/resources/StackMapExample2.java | 12 +
src/test/resources/com/foo/Foo.class | Bin 0 -> 770 bytes
...JavaLanguageParser$ClassBlockContext.class | Bin 0 -> 2624 bytes
src/test/resources/issue369/Test.class | Bin 0 -> 283 bytes
src/test/resources/jira368/Test.class | Bin 0 -> 162 bytes
.../test$method name with () in it$1.class | Bin 0 -> 1191 bytes
.../issue51980/{Test.class => Test.classx} | Bin
.../issue51989/{Test.class => Test.classx} | Bin
.../issue52168/{Test.class => Test.classx} | Bin
.../issue53543/{Test.class => Test.classx} | Bin
.../issue53544a/{Test.class => Test.classx} | Bin
.../issue53620/{Test.class => Test.classx} | Bin
.../resources/ossfuzz/issue53676/Test.classx | Bin 0 -> 26 bytes
.../resources/ossfuzz/issue54119/Test.classx | Bin 0 -> 24 bytes
.../resources/ossfuzz/issue54254/Test.classx | Bin 0 -> 42 bytes
src/test/resources/ossfuzz/readme.txt | 19 +
264 files changed, 4094 insertions(+), 1506 deletions(-)
create mode 100644 src/main/java/org/apache/bcel/classfile/InvalidMethodSignatureException.java
create mode 100644 src/main/java/org/apache/bcel/classfile/package-info.java
create mode 100644 src/main/java/org/apache/bcel/generic/package-info.java
create mode 100644 src/main/java/org/apache/bcel/package-info.java
create mode 100644 src/main/java/org/apache/bcel/util/package-info.java
create mode 100644 src/main/java/org/apache/bcel/verifier/exc/package-info.java
create mode 100644 src/main/java/org/apache/bcel/verifier/package-info.java
create mode 100644 src/main/java/org/apache/bcel/verifier/statics/package-info.java
create mode 100644 src/main/java/org/apache/bcel/verifier/structurals/package-info.java
create mode 100644 src/test/java/org/apache/bcel/AnnotationEntryTest.java
create mode 100644 src/test/java/org/apache/bcel/classfile/ConstantTest.java
create mode 100644 src/test/java/org/apache/bcel/classfile/FieldTest.java
create mode 100644 src/test/java/org/apache/bcel/classfile/InvalidMethodSigantureTestCase.java
create mode 100644 src/test/java/org/apache/bcel/classfile/SignatureTestCase.java
create mode 100644 src/test/java/org/apache/bcel/classfile/StackMapTest.java
create mode 100644 src/test/java/org/apache/bcel/classfile/TestJira368.java
create mode 100644 src/test/java/org/apache/bcel/data/SWAP.java
create mode 100644 src/test/java/org/apache/bcel/generic/ClassGenTest.java
create mode 100644 src/test/java/org/apache/bcel/generic/FieldGenTest.java
create mode 100644 src/test/java/org/apache/bcel/generic/InstructionFactoryTestCase.java
create mode 100644 src/test/java/org/apache/bcel/verifier/JiraBcel369TestCase.java
create mode 100644 src/test/java/org/apache/bcel/verifier/JiraBcel369TestFixture.java
create mode 100644 src/test/java/org/apache/bcel/verifier/JiraBcel370TestCase.java
create mode 100644 src/test/java/org/apache/bcel/verifier/VerifierMainTestCase.java
create mode 100644 src/test/java/org/apache/bcel/verifier/VerifierThrowTestCase.java
create mode 100644 src/test/java/org/apache/bcel/verifier/input/FieldVerifierChildClass.java
create mode 100644 src/test/java/org/apache/bcel/verifier/input/FieldVerifierSuperClass.java
create mode 100644 src/test/java/org/apache/bcel/verifier/input/StaticFieldVerifierChildClass.java
create mode 100644 src/test/java/org/apache/bcel/verifier/input/StaticFieldVerifierSuperClass.java
create mode 100644 src/test/java/org/apache/bcel/verifier/statics/Pass3aVerifierTestCase.java
create mode 100644 src/test/java/org/apache/bcel/verifier/structurals/InstConstraintVisitorTestCase.java
create mode 100644 src/test/java/org/apache/bcel/verifier/tests/JvmOpCodes.java
create mode 100644 src/test/java/org/apache/bcel/verifier/tests/TestThrow01Creator.java
create mode 100644 src/test/resources/StackMapExample.class
create mode 100644 src/test/resources/StackMapExample.java
create mode 100644 src/test/resources/StackMapExample2.class
create mode 100644 src/test/resources/StackMapExample2.java
create mode 100644 src/test/resources/com/foo/Foo.class
create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/grammar/java/JavaLanguageParser$ClassBlockContext.class
create mode 100644 src/test/resources/issue369/Test.class
create mode 100644 src/test/resources/jira368/Test.class
create mode 100644 src/test/resources/kotlin/test$method name with () in it$1.class
rename src/test/resources/ossfuzz/issue51980/{Test.class => Test.classx} (100%)
rename src/test/resources/ossfuzz/issue51989/{Test.class => Test.classx} (100%)
rename src/test/resources/ossfuzz/issue52168/{Test.class => Test.classx} (100%)
rename src/test/resources/ossfuzz/issue53543/{Test.class => Test.classx} (100%)
rename src/test/resources/ossfuzz/issue53544a/{Test.class => Test.classx} (100%)
rename src/test/resources/ossfuzz/issue53620/{Test.class => Test.classx} (100%)
create mode 100644 src/test/resources/ossfuzz/issue53676/Test.classx
create mode 100644 src/test/resources/ossfuzz/issue54119/Test.classx
create mode 100644 src/test/resources/ossfuzz/issue54254/Test.classx
create mode 100644 src/test/resources/ossfuzz/readme.txt
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 97a7c25e47..e4b3e131be 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -26,12 +26,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- java: [ 8, 11, 17 ]
+ java: [ 8, 11, 17, 21 ]
steps:
- - uses: actions/checkout@v3.1.0
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up JDK ${{ matrix.java }}
- uses: actions/setup-java@v3.6.0
+ uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8986d489e4..cd33383389 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -49,13 +49,13 @@ Getting Started
---------------
+ Make sure you have a [JIRA account](https://issues.apache.org/jira/).
-+ Make sure you have a [GitHub account](https://github.com/signup/free).
++ Make sure you have a [GitHub account](https://github.com/signup/free). This is not essential, but makes providing patches much easier.
+ If you're planning to implement a new feature it makes sense to discuss your changes on the [dev list](https://commons.apache.org/mail-lists.html) first. This way you can make sure you're not wasting your time on something that isn't considered to be in Apache Commons BCEL's scope.
+ Submit a [Jira Ticket][jira] for your issue, assuming one does not already exist.
+ Clearly describe the issue including steps to reproduce when it is a bug.
+ Make sure you fill in the earliest version that you know has the issue.
+ Find the corresponding [repository on GitHub](https://github.com/apache/?query=commons-),
-[fork](https://help.github.com/articles/fork-a-repo/) and check out your forked repository.
+[fork](https://help.github.com/articles/fork-a-repo/) and check out your forked repository. If you don't have a GitHub account, you can still clone the Commons repository.
Making Changes
--------------
@@ -109,7 +109,6 @@ Additional Resources
+ [General GitHub documentation](https://help.github.com/)
+ [GitHub pull request documentation](https://help.github.com/articles/creating-a-pull-request/)
+ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
-+ `#apache-commons` IRC channel on `irc.freenode.net`
[cla]:https://www.apache.org/licenses/#clas
[jira]:https://issues.apache.org/jira/browse/BCEL
diff --git a/NOTICE.txt b/NOTICE.txt
index 3cc409c3c0..f3ff767ae2 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,5 +1,5 @@
Apache Commons BCEL
-Copyright 2004-2022 The Apache Software Foundation
+Copyright 2004-2024 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (https://www.apache.org/).
diff --git a/README-codespecs.txt b/README-codespecs.txt
index 47f8e257d2..75b02b4b78 100644
--- a/README-codespecs.txt
+++ b/README-codespecs.txt
@@ -11,10 +11,12 @@ To build this project
---------------------
```
-mvn verify
+mvn -B clean verify
```
-The `.jar` file is found at, for example, `target/bcel-6.2.0.1.jar`.
+(You may need to add -Drat.skip=true if you have local untracked files.)
+
+The `.jar` file will be found in the target subdirectory at, for example, `target/bcel-6.8.1.jar`.
To update to a newer version of the upstream library
diff --git a/README.md b/README.md
index cb7a03674c..4e10557350 100644
--- a/README.md
+++ b/README.md
@@ -43,12 +43,12 @@
Apache Commons BCEL
===================
-[![GitHub Actions Status](https://github.com/apache/commons-bcel/workflows/Java%20CI/badge.svg)](https://github.com/apache/commons-bcel/actions)
+[![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.7.0.svg)](https://javadoc.io/doc/org.apache.bcel/bcel/6.7.0)
-[![CodeQL](https://github.com/apache/commons-bcel/workflows/CodeQL/badge.svg)](hhttps://github.com/apache/commons-bcel/actions/workflows/codeql-analysis.yml?query=workflow%3ACodeQL)
-[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/apache/commons-text/badge)](https://api.securityscorecards.dev/projects/github.com/apache/commons-text)
+[![Javadocs](https://javadoc.io/badge/org.apache.bcel/bcel/6.8.1.svg)](https://javadoc.io/doc/org.apache.bcel/bcel/6.8.1)
+[![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
@@ -57,29 +57,37 @@ Documentation
More information can be found on the [Apache Commons BCEL homepage](https://commons.apache.org/proper/commons-bcel).
The [Javadoc](https://commons.apache.org/proper/commons-bcel/apidocs) can be browsed.
-Questions related to the usage of Apache Commons BCEL should be posted to the [user mailing list][ml].
+Questions related to the usage of Apache Commons BCEL should be posted to the [user mailing list](https://commons.apache.org/mail-lists.html).
-Where can I get the latest release?
------------------------------------
+Getting the latest release
+--------------------------
You can download source and binaries from our [download page](https://commons.apache.org/proper/commons-bcel/download_bcel.cgi).
-Alternatively you can pull it from the central Maven repositories:
+Alternatively, you can pull it from the central Maven repositories:
```xml
org.apache.bcel
bcel
- 6.7.0
+ 6.8.1
```
+Building
+--------
+
+Building requires a Java JDK and [Apache Maven](https://maven.apache.org/).
+The required Java version is found in the `pom.xml` as the `maven.compiler.source` property.
+
+From a command shell, run `mvn` without arguments to invoke the default Maven goal to run all tests and checks.
+
Contributing
------------
We accept Pull Requests via GitHub. The [developer mailing list](https://commons.apache.org/mail-lists.html) is the main channel of communication for contributors.
There are some guidelines which will make applying PRs easier for us:
+ No tabs! Please use spaces for indentation.
-+ Respect the code style.
++ 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```.
@@ -88,13 +96,13 @@ You can learn more about contributing via GitHub in our [contribution guidelines
License
-------
-This code is under the [Apache Licence v2](https://www.apache.org/licenses/LICENSE-2.0).
+This code is licensed under the [Apache License v2](https://www.apache.org/licenses/LICENSE-2.0).
See the `NOTICE.txt` file for required notices and attributions.
-Donations
----------
-You like Apache Commons BCEL? Then [donate back to the ASF](https://www.apache.org/foundation/contributing.html) to support the development.
+Donating
+--------
+You like Apache Commons BCEL? Then [donate back to the ASF](https://www.apache.org/foundation/contributing.html) to support development.
Additional Resources
--------------------
@@ -103,59 +111,8 @@ Additional Resources
+ [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/BCEL)
+ [Apache Commons Slack Channel](https://the-asf.slack.com/archives/C60NVB8AD)
+ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
-+ `#apache-commons` IRC channel on `irc.freenode.org`
Apache Commons Components
-------------------------
-| Component | GitHub Repository | Apache Homepage |
-| --------- | ----------------- | ----------------|
-| Apache Commons BCEL | [commons-bcel](https://github.com/apache/commons-bcel) | [commons-bcel](https://commons.apache.org/proper/commons-bcel) |
-| Apache Commons Beanutils | [commons-beanutils](https://github.com/apache/commons-beanutils) | [commons-beanutils](https://commons.apache.org/proper/commons-beanutils) |
-| Apache Commons BSF | [commons-bsf](https://github.com/apache/commons-bsf) | [commons-bsf](https://commons.apache.org/proper/commons-bsf) |
-| Apache Commons Build-plugin | [commons-build-plugin](https://github.com/apache/commons-build-plugin) | [commons-build-plugin](https://commons.apache.org/proper/commons-build-plugin) |
-| Apache Commons Chain | [commons-chain](https://github.com/apache/commons-chain) | [commons-chain](https://commons.apache.org/proper/commons-chain) |
-| Apache Commons CLI | [commons-cli](https://github.com/apache/commons-cli) | [commons-cli](https://commons.apache.org/proper/commons-cli) |
-| Apache Commons Codec | [commons-codec](https://github.com/apache/commons-codec) | [commons-codec](https://commons.apache.org/proper/commons-codec) |
-| Apache Commons Collections | [commons-collections](https://github.com/apache/commons-collections) | [commons-collections](https://commons.apache.org/proper/commons-collections) |
-| Apache Commons Compress | [commons-compress](https://github.com/apache/commons-compress) | [commons-compress](https://commons.apache.org/proper/commons-compress) |
-| Apache Commons Configuration | [commons-configuration](https://github.com/apache/commons-configuration) | [commons-configuration](https://commons.apache.org/proper/commons-configuration) |
-| Apache Commons Crypto | [commons-crypto](https://github.com/apache/commons-crypto) | [commons-crypto](https://commons.apache.org/proper/commons-crypto) |
-| Apache Commons CSV | [commons-csv](https://github.com/apache/commons-csv) | [commons-csv](https://commons.apache.org/proper/commons-csv) |
-| Apache Commons Daemon | [commons-daemon](https://github.com/apache/commons-daemon) | [commons-daemon](https://commons.apache.org/proper/commons-daemon) |
-| Apache Commons DBCP | [commons-dbcp](https://github.com/apache/commons-dbcp) | [commons-dbcp](https://commons.apache.org/proper/commons-dbcp) |
-| Apache Commons Dbutils | [commons-dbutils](https://github.com/apache/commons-dbutils) | [commons-dbutils](https://commons.apache.org/proper/commons-dbutils) |
-| Apache Commons Digester | [commons-digester](https://github.com/apache/commons-digester) | [commons-digester](https://commons.apache.org/proper/commons-digester) |
-| Apache Commons Email | [commons-email](https://github.com/apache/commons-email) | [commons-email](https://commons.apache.org/proper/commons-email) |
-| Apache Commons Exec | [commons-exec](https://github.com/apache/commons-exec) | [commons-exec](https://commons.apache.org/proper/commons-exec) |
-| Apache Commons Fileupload | [commons-fileupload](https://github.com/apache/commons-fileupload) | [commons-fileupload](https://commons.apache.org/proper/commons-fileupload) |
-| Apache Commons Functor | [commons-functor](https://github.com/apache/commons-functor) | [commons-functor](https://commons.apache.org/proper/commons-functor) |
-| Apache Commons Geometry | [commons-geometry](https://github.com/apache/commons-geometry) | [commons-geometry](https://commons.apache.org/proper/commons-geometry) |
-| Apache Commons Graph | [commons-graph](https://github.com/apache/commons-graph) | [commons-graph](https://commons.apache.org/proper/commons-graph) |
-| Apache Commons Imaging | [commons-imaging](https://github.com/apache/commons-imaging) | [commons-imaging](https://commons.apache.org/proper/commons-imaging) |
-| Apache Commons IO | [commons-io](https://github.com/apache/commons-io) | [commons-io](https://commons.apache.org/proper/commons-io) |
-| Apache Commons JCI | [commons-jci](https://github.com/apache/commons-jci) | [commons-jci](https://commons.apache.org/proper/commons-jci) |
-| Apache Commons JCS | [commons-jcs](https://github.com/apache/commons-jcs) | [commons-jcs](https://commons.apache.org/proper/commons-jcs) |
-| Apache Commons Jelly | [commons-jelly](https://github.com/apache/commons-jelly) | [commons-jelly](https://commons.apache.org/proper/commons-jelly) |
-| Apache Commons Jexl | [commons-jexl](https://github.com/apache/commons-jexl) | [commons-jexl](https://commons.apache.org/proper/commons-jexl) |
-| Apache Commons Jxpath | [commons-jxpath](https://github.com/apache/commons-jxpath) | [commons-jxpath](https://commons.apache.org/proper/commons-jxpath) |
-| Apache Commons Lang | [commons-lang](https://github.com/apache/commons-lang) | [commons-lang](https://commons.apache.org/proper/commons-lang) |
-| Apache Commons Logging | [commons-logging](https://github.com/apache/commons-logging) | [commons-logging](https://commons.apache.org/proper/commons-logging) |
-| Apache Commons Math | [commons-math](https://github.com/apache/commons-math) | [commons-math](https://commons.apache.org/proper/commons-math) |
-| Apache Commons Net | [commons-net](https://github.com/apache/commons-net) | [commons-net](https://commons.apache.org/proper/commons-net) |
-| Apache Commons Numbers | [commons-numbers](https://github.com/apache/commons-numbers) | [commons-numbers](https://commons.apache.org/proper/commons-numbers) |
-| Apache Commons Parent | [commons-parent](https://github.com/apache/commons-parent) | [commons-parent](https://commons.apache.org/proper/commons-parent) |
-| Apache Commons Pool | [commons-pool](https://github.com/apache/commons-pool) | [commons-pool](https://commons.apache.org/proper/commons-pool) |
-| Apache Commons Proxy | [commons-proxy](https://github.com/apache/commons-proxy) | [commons-proxy](https://commons.apache.org/proper/commons-proxy) |
-| Apache Commons RDF | [commons-rdf](https://github.com/apache/commons-rdf) | [commons-rdf](https://commons.apache.org/proper/commons-rdf) |
-| Apache Commons Release-plugin | [commons-release-plugin](https://github.com/apache/commons-release-plugin) | [commons-release-plugin](https://commons.apache.org/proper/commons-release-plugin) |
-| Apache Commons Rng | [commons-rng](https://github.com/apache/commons-rng) | [commons-rng](https://commons.apache.org/proper/commons-rng) |
-| Apache Commons Scxml | [commons-scxml](https://github.com/apache/commons-scxml) | [commons-scxml](https://commons.apache.org/proper/commons-scxml) |
-| Apache Commons Signing | [commons-signing](https://github.com/apache/commons-signing) | [commons-signing](https://commons.apache.org/proper/commons-signing) |
-| Apache Commons Skin | [commons-skin](https://github.com/apache/commons-skin) | [commons-skin](https://commons.apache.org/proper/commons-skin) |
-| Apache Commons Statistics | [commons-statistics](https://github.com/apache/commons-statistics) | [commons-statistics](https://commons.apache.org/proper/commons-statistics) |
-| Apache Commons Testing | [commons-testing](https://github.com/apache/commons-testing) | [commons-testing](https://commons.apache.org/proper/commons-testing) |
-| Apache Commons Text | [commons-text](https://github.com/apache/commons-text) | [commons-text](https://commons.apache.org/proper/commons-text) |
-| Apache Commons Validator | [commons-validator](https://github.com/apache/commons-validator) | [commons-validator](https://commons.apache.org/proper/commons-validator) |
-| Apache Commons VFS | [commons-vfs](https://github.com/apache/commons-vfs) | [commons-vfs](https://commons.apache.org/proper/commons-vfs) |
-| Apache Commons Weaver | [commons-weaver](https://github.com/apache/commons-weaver) | [commons-weaver](https://commons.apache.org/proper/commons-weaver) |
+Please see the [list of components](https://commons.apache.org/components.html)
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index b99db0b263..926f741a78 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -1,3 +1,161 @@
+ Apache Commons BCEL
+ Version 6.8.1
+ RELEASE NOTES
+
+
+INTRODUCTION:
+
+The Apache Commons BCEL team is pleased to announce the release of
+Apache Commons BCEL 6.8.1.
+
+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.
+
+FIXED BUGS:
+===========
+
+o Replace internal use of StringBuffer with StringBuilder. Thanks to Gary Gregory.
+o BCEL-370: CONSTANT_Dynamic is not handled in LDC #254. Thanks to Gary Gregory.
+o BCELComparator now uses generics. Thanks to Gary Gregory.
+o Avoid NullPointerException in ClassGen.BCELComparator#equals() and ClassGen.BCELComparator#hashCode(). Thanks to Gary Gregory.
+o Avoid NullPointerException in Constant.BCELComparator#equals() and Constant.BCELComparator#hashCode(). Thanks to Gary Gregory.
+o Avoid NullPointerException in Field.BCELComparator#equals() and Field.BCELComparator#hashCode(). Thanks to Gary Gregory.
+o Avoid NullPointerException in FieldGen.BCELComparator#equals() and FieldGen.BCELComparator#hashCode(). Thanks to Gary Gregory.
+o Avoid NullPointerException in JavaClass.BCELComparator#equals() and JavaClass.BCELComparator#hashCode(). Thanks to Gary Gregory.
+o Avoid NullPointerException in Method.BCELComparator#equals() and Method.BCELComparator#hashCode(). Thanks to Gary Gregory.
+o Avoid NullPointerException in MethodGen.BCELComparator#equals() and MethodGen.BCELComparator#hashCode(). Thanks to Gary Gregory.
+
+CHANGES:
+========
+
+o Bump GitHub various actions for CI builds. Thanks to Dependabot.
+o Bump jna.version from 5.13.0 to 5.14.0 #250. Thanks to Dependabot.
+o Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.21 to 1.9.22 #252. Thanks to Dependabot.
+o Bump org.apache.commons:commons-exec from 1.3 to 1.4.0 #255. Thanks to Dependabot.
+
+
+Historical list of changes: https://commons.apache.org/proper/commons-bcelchanges-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.8.0
+ RELEASE NOTES
+
+
+INTRODUCTION:
+
+The Apache Commons BCEL team is pleased to announce the release of
+Apache Commons BCEL 6.8.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.
+
+NEW FEATURES:
+=============
+
+o Add and use InvalidMethodSignatureException extending ClassFormatException. Thanks to Gary Gregory.
+o Increase code coverage in Class2HTMLTestCase with new test input Java4Example #186. Thanks to nbauma109.
+o Add verifier tests on some opcodes #180. Thanks to nbauma109.
+o Added signature test cases for class/method, and bad signatures #182. Thanks to nbauma109.
+o Add Const.MAJOR_20. Thanks to Gary Gregory.
+o Add Const.MINOR_20. Thanks to Gary Gregory.
+o Add Const.MAJOR_21. Thanks to Gary Gregory.
+o Add Const.MINOR_21. Thanks to Gary Gregory.
+o [Bcelifier] stackmap support to pass JDK verifier #177. Thanks to nbauma109, Gary Gregory, Mark Roberts.
+o Fix SpotBugs [ERROR] Class org.apache.bcel.util.ClassVector defines non-transient non-serializable instance field vec [org.apache.bcel.util.ClassVector] In ClassVector.java SE_BAD_FIELD. Thanks to Gary Gregory.
+o Fix SpotBugs [ERROR] Switch statement found in org.apache.bcel.util.BCELFactory.visitAllocationInstruction(AllocationInstruction) where one case falls through to the next case [org.apache.bcel.util.BCELFactory, org.apache.bcel.util.BCELFactory] At BCELFactory.java:[lines 188-191]Another occurrence at BCELFactory.java:[lines 192-196] SF_SWITCH_FALLTHROUGH. Thanks to Gary Gregory.
+
+FIXED BUGS:
+===========
+
+o When parsing an class with an invalid constant reference, ensure ClassParser.parse() throws ClassFormatException, not NullPointerException. Thanks to OSS-Fuzz.
+o Ensure that references to a constant pool entry with index zero trigger a ClassFormatException, not a NullPointerException. Thanks to OSS-Fuzz.
+o Ensure that references to the unused constant pool entry after a long/double entry triggers a ClassFormatException, not a NullPointerException. Thanks to OSS-Fuzz.
+o Test and coverage of InstructionFactory #190. Thanks to nbauma109.
+o Verifier: test and coverage for SWAP instruction #188. Thanks to nbauma109.
+o Exception parsing Kotlin class with 'fun `method name with () in it`()' #205. Thanks to Jason Copenhaver, Gary Gregory.
+o Fix null pointers in AnnotationEntry #213. Thanks to nbauma109, Gary Gregory.
+o Field not found, search field in both super class and implemented interfaces (5x duplicated code to find field by name and type is refactored to a new method and now supports package-private) #181. Thanks to nbauma109.
+o BCEL-366: Use alternative name for broken classes under test #220. Thanks to Slawomir Jaranowski.
+o BCEL-367: Fixes java.lang.IndexOutOfBoundsException for ATHROW on empty stack #223. Thanks to Katherine Hough, Gary Gregory.
+o BCEL-368: Fixes java.lang.StackOverflowError in Select#toString(boolean) #229. Thanks to Katherine Hough, Gary Gregory.
+o Fix for type.getType(...) use on non-signature type names #221. Thanks to nbauma109, Judit Knoll, Gary Gregory.
+o Fix EmptyVisitorTestCase on Java 21. Thanks to Gary Gregory.
+
+CHANGES:
+========
+
+o Bump commons-parent from 54 to 65 #189, #198, #222. Thanks to Gary Gregory, Dependabot.
+o Bump jna.version from 5.12.1 to 5.13.0 #203. Thanks to Dependabot.
+o Bump kotlin-stdlib from 1.8.10 to 1.9.21 #217, #219, #227, #231, #235, #245, #247. Thanks to Dependabot.
+o Bump commons-io from 2.11.0 to 2.15.1. Thanks to Dependabot.
+o Bump commons-lang3 from 3.12.0 to 3.14.0. Thanks to Gary Gregory.
+o Bump org.codehaus.mojo:exec-maven-plugin from 3.1.0 to 3.1.1 #246. Thanks to Gary Gregory.
+
+
+Historical list of changes: https://commons.apache.org/proper/commons-bcelchanges-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.7.0
RELEASE NOTES
@@ -85,7 +243,7 @@ o Bump japicmp from 0.16.0 to 0.17.1. Thanks to Gary Gregory.
Historical list of changes: https://commons.apache.org/proper/commons-bcelchanges-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 Apache Commons BCEL website:
+patches, or suggestions for improvement, see the Apache Commons BCEL website:
https://commons.apache.org/proper/commons-bcel
@@ -144,7 +302,7 @@ o Bump pmd from 6.50.0 to 6.51.0. Thanks to Gary Gregory.
Historical list of changes: https://commons.apache.org/proper/commons-bcelchanges-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 Apache Commons BCEL website:
+patches, or suggestions for improvement, see the Apache Commons BCEL website:
https://commons.apache.org/proper/commons-bcel
@@ -267,7 +425,7 @@ o Bump junit-jupiter from 5.7.0 to 5.9.1 #78, #90, #101, #112, #135. T
o Bump jna.version from 5.6.0 to 5.12.1 #84, #102, #109, #120, #131. Thanks to Dependabot.
o Bump jmh.version from 1.19 to 1.35 #92, #100, #122. Thanks to Dependabot.
o Bump maven-javadoc-plugin from 3.2.0 to 3.4.1. Thanks to Gary Gregory.
-o Bump Bump maven-bundle-plugin from 5.1.1 to 5.1.8. Thanks to Gary Gregory.
+o Bump maven-bundle-plugin from 5.1.1 to 5.1.8. Thanks to Gary Gregory.
o Bump taglist-maven-plugin from 2.4 to 3.0.0 #114. Thanks to Dependabot.
o Bump spotbugs-maven-plugin from 4.5.3.0 to 4.7.2.1 #128, #132, #136, #144, #155. Thanks to Gary Gregory, Dependabot.
o Bump spotbugs from 4.5.3 to 4.7.1. Thanks to Gary Gregory.
@@ -276,7 +434,7 @@ o Bump spotbugs from 4.5.3 to 4.7.1. Thanks to Gary Gregory.
Historical list of changes: https://commons.apache.org/proper/commons-bcelchanges-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 Apache Commons BCEL website:
+patches, or suggestions for improvement, see the Apache Commons BCEL website:
https://commons.apache.org/proper/commons-bcel
@@ -407,7 +565,7 @@ o Update build from Checkstyle Maven Plugin 3.0.0 to 3.1.0. Thanks to
Historical list of changes: https://commons.apache.org/proper/commons-bcelchanges-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 Apache Commons BCEL website:
+patches, or suggestions for improvement, see the Apache Commons BCEL website:
https://commons.apache.org/proper/commons-bcel
@@ -481,7 +639,7 @@ o Update tests from JNA 5.3.1. to 5.4.0. Thanks to Gary Gregory.
Historical list of changes: https://commons.apache.org/proper/commons-bcelchanges-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 Apache Commons BCEL website:
+patches, or suggestions for improvement, see the Apache Commons BCEL website:
https://commons.apache.org/proper/commons-bcel
diff --git a/docs/verifier/JustIce.lyx b/docs/verifier/JustIce.lyx
index 02e3858a6b..3496cf8f5e 100644
--- a/docs/verifier/JustIce.lyx
+++ b/docs/verifier/JustIce.lyx
@@ -8403,7 +8403,7 @@ _w}
instructions have possibly not been symbolically executed yet and thus
bear no type information at the time of merging.
In this scenario, an instruction in a subroutine plays multiple roles;
- one for each occurence of a
+ one for each occurrence of a
\latex latex
\backslash
diff --git a/pom.xml b/pom.xml
index 624d4830c8..d74f67a921 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,14 +27,13 @@
org.apache.commons
commons-parent
- 54
-
+ 65
org.apache.bcel
bcel
jar
- 6.7.0
+ 6.8.1
Apache Commons BCEL
Apache Commons Bytecode Engineering Library
@@ -43,22 +42,21 @@
- 3.25.0
+ 3.42.0
UTF-8
UTF-8
1.8
1.8
bcel
org.apache.bcel
- 6.7.0
+ 6.8.1
+ 6.8.2
true
RC1
- 6.6.1
- (Java 8)
+ 6.8.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}
- Gary Gregory
- 86fdc7e2a11262cb
org.apache.${commons.componentid}
org.apache.bcel.*;version=${project.version};-noimport:=true
@@ -67,21 +65,11 @@
BCEL
12314220
- 3.0.0-M7
- 3.2.0
- 5.12.1
- 0.17.1
+ 4.11.0
+ 3.25.1
+ 5.14.0
false
- true
- 0.8.8
- 3.4.1
- 5.1.8
- 4.7.3.0
- 4.7.3
- 6.3.1
- 3.19.0
- 6.52.0
- 5.9.1
+
org.checkerframework.checker.interning.InterningChecker
org.checkerframework.checker.nullness.NullnessChecker
@@ -105,121 +93,6 @@
https://github.com/apache/commons-bcel/actions
-
-
- Dave Brosius
- dbrosius
- dbrosius at mebigfatguy.com
-
-
-
- Torsten Curdt
- tcurdt
- tcurdt at apache.org
- ASF
- http://www.apache.org/
- +1
-
-
-
- Markus Dahm
- mdahm
- m.dahm at gmx.de
- it-frameworksolutions
-
-
-
- Jason van Zyl
- jason at zenplex.com
-
-
-
- ggregory
- Gary Gregory
- ggregory at apache.org
- https://www.garygregory.com
- The Apache Software Foundation
- https://www.apache.org/
-
- PMC Member
-
- America/New_York
-
- https://people.apache.org/~ggregory/img/garydgregory80.png
-
-
-
-
-
-
-
-
- Enver Haase
- enver at convergence.de
-
-
-
- David Dixon-Peugh
- dixonpeugh at yahoo.com
-
-
-
- Patrick Beard
- beard at netscape.com
-
-
-
- Conor MacNeill
- conor at cortexbusiness.com.au
-
-
-
- Costin Manolache
- cmanolache at yahoo.com
-
-
-
- Bill Pugh
- bill.pugh at gmail.com
-
-
-
- First Hop Ltd / Torsten Rueger
-
-
-
- Jérôme Leroux
-
-
-
- Mark Roberts
-
-
-
- Sam Yoon
-
-
-
- Arturo Bernal
-
-
-
-
-
-
- BCEL User List
- user-subscribe@commons.apache.org
- user-unsubscribe@commons.apache.org
- https://mail-archives.apache.org/mod_mbox/commons-user/
-
-
- BCEL Developer List
- dev-subscribe@commons.apache.org
- dev-unsubscribe@commons.apache.org
- https://mail-archives.apache.org/mod_mbox/commons-dev/
-
-
-
jira
https://issues.apache.org/jira/browse/BCEL
@@ -303,13 +176,10 @@
maven-surefire-plugin
-
-
-
- PerformanceTest.report
- false
-
-
+
+
+ false
+
**/*TestCase.java
**/PerformanceTest.java
@@ -319,6 +189,7 @@
**/JDKClassDumpTestCase.java
+ alphabetical
@@ -344,7 +215,6 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- ${checkstyle.plugin.version}
${basedir}/src/conf/checkstyle.xml
@@ -373,13 +243,10 @@
com.github.spotbugs
spotbugs-maven-plugin
- ${commons.spotbugs.plugin.version}
Normal
Default
src/conf/spotbugs-exclude-filter.xml
-
- 17
@@ -423,7 +290,6 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- ${checkstyle.plugin.version}
${basedir}/src/conf/checkstyle.xml
@@ -448,10 +314,10 @@
- org.codehaus.mojo
- taglist-maven-plugin
- 3.0.0
-
+ org.codehaus.mojo
+ taglist-maven-plugin
+ 3.0.0
+
TODO
NOPMD
@@ -484,11 +350,12 @@
com.github.spotbugs
spotbugs-maven-plugin
- ${commons.spotbugs.plugin.version}
Normal
Default
src/conf/spotbugs-exclude-filter.xml
+
+ 9
@@ -500,6 +367,18 @@
junit-jupiter
test
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+ test
+
net.java.dev.jna
jna
@@ -515,10 +394,16 @@
org.apache.commons
commons-lang3
- 3.12.0
+ 3.14.0
+
+
+ commons-io
+ commons-io
+ 2.15.1
+ test
-
+
javax
javaee-api
6.0
@@ -527,7 +412,7 @@
org.apache.commons
commons-exec
- 1.3
+ 1.4.0
test
@@ -544,6 +429,19 @@
test
+
+
+ org.eclipse.jdt
+ ecj
+ 3.26.0
+ test
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ 1.9.22
+ test
+
org.checkerframework
@@ -730,7 +628,7 @@
true
org.apache
- 1.36
+ 1.37
@@ -751,7 +649,7 @@
commons-io
commons-io
- 2.11.0
+ 2.15.1
test
@@ -780,7 +678,6 @@
org.codehaus.mojo
exec-maven-plugin
- 3.1.0
benchmark
@@ -811,4 +708,85 @@
+
+
+ Dave Brosius
+ dbrosius
+ dbrosius at mebigfatguy.com
+
+
+ Torsten Curdt
+ tcurdt
+ tcurdt at apache.org
+ ASF
+ http://www.apache.org/
+ +1
+
+
+ Markus Dahm
+ mdahm
+ m.dahm at gmx.de
+ it-frameworksolutions
+
+
+ Jason van Zyl
+ jason at zenplex.com
+
+
+ ggregory
+ Gary Gregory
+ ggregory at apache.org
+ https://www.garygregory.com
+ The Apache Software Foundation
+ https://www.apache.org/
+
+ PMC Member
+
+ America/New_York
+
+ https://people.apache.org/~ggregory/img/garydgregory80.png
+
+
+
+
+
+ Enver Haase
+ enver at convergence.de
+
+
+ David Dixon-Peugh
+ dixonpeugh at yahoo.com
+
+
+ Patrick Beard
+ beard at netscape.com
+
+
+ Conor MacNeill
+ conor at cortexbusiness.com.au
+
+
+ Costin Manolache
+ cmanolache at yahoo.com
+
+
+ Bill Pugh
+ bill.pugh at gmail.com
+
+
+ First Hop Ltd / Torsten Rueger
+
+
+ Jérôme Leroux
+
+
+ Mark Roberts
+
+
+ Sam Yoon
+
+
+ Arturo Bernal
+
+
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 5a9ec8406a..dc428b35fa 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -36,10 +36,12 @@ mvn changes:announcement-generate -Prelease-notes [-Dchanges.version=nnn]
then tweak the formatting if necessary
and commit
-The type attribute can be add,update,fix,remove.
--->
-
-
+The type attribute can be add,update,fix,remove.
+-->
+
+
Apache Commons BCEL Release Notes
Apache Commons developers
@@ -59,9 +61,62 @@ The type attribute can be add,update,fix,remove.
mvn changes:announcement-generate -Prelease-notes [-Dchanges.version=nnn]
Defining changes.version allows one to create the RN without first removing the SNAPSHOT suffix.
- -->
-
-
+ -->
+
+
+
+
+ Replace internal use of StringBuffer with StringBuilder.
+ CONSTANT_Dynamic is not handled in LDC #254.
+ BCELComparator now uses generics.
+ Avoid NullPointerException in ClassGen.BCELComparator#equals() and ClassGen.BCELComparator#hashCode().
+ Avoid NullPointerException in Constant.BCELComparator#equals() and Constant.BCELComparator#hashCode().
+ Avoid NullPointerException in Field.BCELComparator#equals() and Field.BCELComparator#hashCode().
+ Avoid NullPointerException in FieldGen.BCELComparator#equals() and FieldGen.BCELComparator#hashCode().
+ Avoid NullPointerException in JavaClass.BCELComparator#equals() and JavaClass.BCELComparator#hashCode().
+ Avoid NullPointerException in Method.BCELComparator#equals() and Method.BCELComparator#hashCode().
+ Avoid NullPointerException in MethodGen.BCELComparator#equals() and MethodGen.BCELComparator#hashCode().
+
+ Bump GitHub various actions for CI builds.
+ Bump jna.version from 5.13.0 to 5.14.0 #250.
+ Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.21 to 1.9.22 #252.
+ Bump org.apache.commons:commons-exec from 1.3 to 1.4.0 #255.
+
+
+
+ Add and use InvalidMethodSignatureException extending ClassFormatException.
+ Increase code coverage in Class2HTMLTestCase with new test input Java4Example #186.
+ Add verifier tests on some opcodes #180.
+ Added signature test cases for class/method, and bad signatures #182.
+ Add Const.MAJOR_20.
+ Add Const.MINOR_20.
+ Add Const.MAJOR_21.
+ Add Const.MINOR_21.
+ [Bcelifier] stackmap support to pass JDK verifier #177.
+ Fix SpotBugs [ERROR] Class org.apache.bcel.util.ClassVector defines non-transient non-serializable instance field vec [org.apache.bcel.util.ClassVector] In ClassVector.java SE_BAD_FIELD.
+ Fix SpotBugs [ERROR] Switch statement found in org.apache.bcel.util.BCELFactory.visitAllocationInstruction(AllocationInstruction) where one case falls through to the next case [org.apache.bcel.util.BCELFactory, org.apache.bcel.util.BCELFactory] At BCELFactory.java:[lines 188-191]Another occurrence at BCELFactory.java:[lines 192-196] SF_SWITCH_FALLTHROUGH.
+
+ When parsing an class with an invalid constant reference, ensure ClassParser.parse() throws ClassFormatException, not NullPointerException.
+ Ensure that references to a constant pool entry with index zero trigger a ClassFormatException, not a NullPointerException.
+ Ensure that references to the unused constant pool entry after a long/double entry triggers a ClassFormatException, not a NullPointerException.
+ Test and coverage of InstructionFactory #190.
+ Verifier: test and coverage for SWAP instruction #188.
+ Exception parsing Kotlin class with 'fun `method name with () in it`()' #205.
+ Fix null pointers in AnnotationEntry #213.
+ Field not found, search field in both super class and implemented interfaces (5x duplicated code to find field by name and type is refactored to a new method and now supports package-private) #181.
+ Use alternative name for broken classes under test #220.
+ Fixes java.lang.IndexOutOfBoundsException for ATHROW on empty stack #223.
+ Fixes java.lang.StackOverflowError in Select#toString(boolean) #229.
+ Fix for type.getType(...) use on non-signature type names #221.
+ Fix EmptyVisitorTestCase on Java 21.
+
+ Bump commons-parent from 54 to 65 #189, #198, #222.
+ Bump jna.version from 5.12.1 to 5.13.0 #203.
+ Bump kotlin-stdlib from 1.8.10 to 1.9.21 #217, #219, #227, #231, #235, #245, #247.
+ Bump commons-io from 2.11.0 to 2.15.1.
+ Bump commons-lang3 from 3.12.0 to 3.14.0.
+ Bump org.codehaus.mojo:exec-maven-plugin from 3.1.0 to 3.1.1 #246.
+
Add org.apache.bcel.classfile.ClassFormatException.ClassFormatException(Throwable).
@@ -122,16 +177,16 @@ The type attribute can be add,update,fix,remove.
Bump japicmp from 0.16.0 to 0.17.1.
-
- Keep ConstantPool.getConstant(int) backward compatible with 6.5.0 #157.
-
- Bump actions/setup-java from 3.5.1 to 3.6.0 #159.
- Bump spotbugs from 4.7.2 to 4.7.3.
- Bump spotbugs-maven-plugub from 4.7.2.1 to 4.7.2.2.
- Bump pmd from 6.50.0 to 6.51.0.
+
+ Keep ConstantPool.getConstant(int) backward compatible with 6.5.0 #157.
+
+ Bump actions/setup-java from 3.5.1 to 3.7.0 #159, #179.
+ Bump spotbugs from 4.7.2 to 4.7.3.
+ Bump spotbugs-maven-plugub from 4.7.2.1 to 4.7.2.2.
+ Bump pmd from 6.50.0 to 6.51.0.
-
+
Improve test case coverage; fix Utility.encode bug #46.
Migrate test suite to JUnit Jupiter #68.
JUnit Assertion improvement #69.
@@ -200,10 +255,10 @@ The type attribute can be add,update,fix,remove.
Bump maven-pmd-plugin from 3.13.0 to 3.19. #74, #103, #116, #130, #142, #144.
Bump pmd from 6.44.0 to 6.50.0.
Bump junit-jupiter from 5.7.0 to 5.9.1 #78, #90, #101, #112, #135.
- Bump jna.version from 5.6.0 to 5.12.1 #84, #102, #109, #120, #131.
+ Bump jna.version from 5.6.0 to 5.12.1 #84, #102, #109, #120, #131.
Bump jmh.version from 1.19 to 1.35 #92, #100, #122.
Bump maven-javadoc-plugin from 3.2.0 to 3.4.1.
- Bump Bump maven-bundle-plugin from 5.1.1 to 5.1.8.
+ Bump maven-bundle-plugin from 5.1.1 to 5.1.8.
Bump taglist-maven-plugin from 2.4 to 3.0.0 #114.
Bump spotbugs-maven-plugin from 4.5.3.0 to 4.7.2.1 #128, #132, #136, #144, #155.
Bump spotbugs from 4.5.3 to 4.7.1.
diff --git a/src/changes/release-notes.vm b/src/changes/release-notes.vm
index d0d6abcb20..7d1bcc9a02 100644
--- a/src/changes/release-notes.vm
+++ b/src/changes/release-notes.vm
@@ -23,12 +23,12 @@
INTRODUCTION:
The ${developmentTeam} is pleased to announce the release of
-${project.name} ${version}!
+${project.name} ${version}.
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.
+class: methods, fields, and byte code instructions.
##$introduction.replaceAll("(?
-
+-->
+
+ "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
+ "https://checkstyle.org/dtds/configuration_1_3.dtd">
@@ -65,9 +65,10 @@ limitations under the License.
-
+
-
+
+
@@ -98,7 +99,7 @@ limitations under the License.
-
+
@@ -109,18 +110,17 @@ limitations under the License.
-->
-
-
-
-
-
-
+
+
+
+
+
+
-
+
@@ -138,7 +138,7 @@ limitations under the License.
-->
-
+
@@ -173,7 +173,7 @@ limitations under the License.
-
+
diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml
index f6bc13025a..91be2e1eb6 100644
--- a/src/conf/spotbugs-exclude-filter.xml
+++ b/src/conf/spotbugs-exclude-filter.xml
@@ -26,6 +26,12 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
+
+
+
+
+
+
@@ -54,6 +60,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -77,4 +110,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/examples/ClassDumper.java b/src/examples/ClassDumper.java
index c1772a2a3d..6ebaaab9bb 100644
--- a/src/examples/ClassDumper.java
+++ b/src/examples/ClassDumper.java
@@ -32,7 +32,7 @@
/**
* Display Java .class file data. Output is based on javap tool. Built using the BCEL libary.
*/
-class ClassDumper {
+final class ClassDumper {
private final FileImageInputStream file;
private final String fileName;
@@ -67,7 +67,7 @@ private final String constantToString(final int index) {
/**
* Parses the given Java class file and return an object that represents the contained data, i.e., constants, methods,
* fields and commands. A ClassFormatException is raised, if the file is not a valid .class file. (This does
- * not include verification of the byte code as it is performed by the java interpreter).
+ * not include verification of the byte code as it is performed by the Java interpreter).
*
* @throws IOException
* @throws ClassFormatException
@@ -341,7 +341,7 @@ private final void processVersion() throws IOException, ClassFormatException {
}
-class DumpClass {
+final class DumpClass {
public static void main(final String[] args) throws IOException {
diff --git a/src/examples/JasminVisitor.java b/src/examples/JasminVisitor.java
index e58e45de19..16ef15c55b 100644
--- a/src/examples/JasminVisitor.java
+++ b/src/examples/JasminVisitor.java
@@ -72,7 +72,7 @@ public static void main(final String[] argv) throws Exception {
final String path = className.substring(0, index + 1).replace('.', File.separatorChar);
className = className.substring(index + 1);
- if (!path.equals("")) {
+ if (!path.isEmpty()) {
final File f = new File(path);
f.mkdirs();
}
diff --git a/src/examples/Mini/ASCII_CharStream.java b/src/examples/Mini/ASCII_CharStream.java
index ec1c37e395..a486f44cf9 100644
--- a/src/examples/Mini/ASCII_CharStream.java
+++ b/src/examples/Mini/ASCII_CharStream.java
@@ -32,17 +32,17 @@ public final class ASCII_CharStream {
static private int bufline[];
static private int bufcolumn[];
- static private int column = 0;
+ static private int column;
static private int line = 1;
- static private boolean prevCharIsCR = false;
- static private boolean prevCharIsLF = false;
+ static private boolean prevCharIsCR;
+ static private boolean prevCharIsLF;
static private java.io.Reader inputStream;
static private char[] buffer;
- static private int maxNextCharInd = 0;
- static private int inBuf = 0;
+ static private int maxNextCharInd;
+ static private int inBuf;
/**
* Method to adjust line and column numbers for the start of a token.
@@ -109,8 +109,8 @@ static public void Done() {
static private void ExpandBuff(final boolean wrapAround) {
final char[] newbuffer = new char[bufsize + 2048];
- final int newbufline[] = new int[bufsize + 2048];
- final int newbufcolumn[] = new int[bufsize + 2048];
+ final int[] newbufline = new int[bufsize + 2048];
+ final int[] newbufcolumn = new int[bufsize + 2048];
try {
if (wrapAround) {
@@ -237,28 +237,28 @@ static public char readChar() throws IOException {
return c;
}
- static public void ReInit(final java.io.InputStream dstream, final int startline, final int startcolumn) {
- ReInit(dstream, startline, startcolumn, 4096);
+ static public void ReInit(final java.io.InputStream dstream, final int startLine, final int startColumn) {
+ ReInit(dstream, startLine, startColumn, 4096);
}
- static public void ReInit(final java.io.InputStream dstream, final int startline, final int startcolumn, final int buffersize) {
- ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ static public void ReInit(final java.io.InputStream dstream, final int startLine, final int startColumn, final int bufferSize) {
+ ReInit(new java.io.InputStreamReader(dstream), startLine, startColumn, 4096);
}
- static public void ReInit(final java.io.Reader dstream, final int startline, final int startcolumn) {
- ReInit(dstream, startline, startcolumn, 4096);
+ static public void ReInit(final java.io.Reader dstream, final int startLine, final int startColumn) {
+ ReInit(dstream, startLine, startColumn, 4096);
}
- static public void ReInit(final java.io.Reader dstream, final int startline, final int startcolumn, final int buffersize) {
+ static public void ReInit(final java.io.Reader dstream, final int startLine, final int startColumn, final int bufferSize) {
inputStream = dstream;
- line = startline;
- column = startcolumn - 1;
-
- if (buffer == null || buffersize != buffer.length) {
- available = bufsize = buffersize;
- buffer = new char[buffersize];
- bufline = new int[buffersize];
- bufcolumn = new int[buffersize];
+ line = startLine;
+ column = startColumn - 1;
+
+ if (buffer == null || bufferSize != buffer.length) {
+ available = bufsize = bufferSize;
+ buffer = new char[bufferSize];
+ bufline = new int[bufferSize];
+ bufcolumn = new int[bufferSize];
}
prevCharIsLF = prevCharIsCR = false;
tokenBegin = inBuf = maxNextCharInd = 0;
@@ -299,31 +299,31 @@ static private void UpdateLineColumn(final char c) {
bufcolumn[bufpos] = column;
}
- public ASCII_CharStream(final java.io.InputStream dstream, final int startline, final int startcolumn) {
- this(dstream, startline, startcolumn, 4096);
+ public ASCII_CharStream(final java.io.InputStream dstream, final int startLine, final int startColumn) {
+ this(dstream, startLine, startColumn, 4096);
}
- public ASCII_CharStream(final java.io.InputStream dstream, final int startline, final int startcolumn, final int buffersize) {
- this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ public ASCII_CharStream(final java.io.InputStream dstream, final int startLine, final int startColumn, final int bufferSize) {
+ this(new java.io.InputStreamReader(dstream), startLine, startColumn, 4096);
}
- public ASCII_CharStream(final java.io.Reader dstream, final int startline, final int startcolumn) {
- this(dstream, startline, startcolumn, 4096);
+ public ASCII_CharStream(final java.io.Reader dstream, final int startLine, final int startColumn) {
+ this(dstream, startLine, startColumn, 4096);
}
- public ASCII_CharStream(final java.io.Reader dstream, final int startline, final int startcolumn, final int buffersize) {
+ public ASCII_CharStream(final java.io.Reader dstream, final int startLine, final int startColumn, final int bufferSize) {
if (inputStream != null) {
throw new Error("\n ERROR: Second call to the constructor of a static ASCII_CharStream. You must\n"
+ " either use ReInit() or set the JavaCC option STATIC to false\n" + " during the generation of this class.");
}
inputStream = dstream;
- line = startline;
- column = startcolumn - 1;
+ line = startLine;
+ column = startColumn - 1;
- available = bufsize = buffersize;
- buffer = new char[buffersize];
- bufline = new int[buffersize];
- bufcolumn = new int[buffersize];
+ available = bufsize = bufferSize;
+ buffer = new char[bufferSize];
+ bufline = new int[bufferSize];
+ bufcolumn = new int[bufferSize];
}
}
diff --git a/src/examples/Mini/ASTFunDecl.java b/src/examples/Mini/ASTFunDecl.java
index 52feecbb7b..1f88ddf945 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 StringBuffer buf = new StringBuffer();
+ final StringBuilder buf = new StringBuilder();
body.code(buf);
out.println(getVarDecls());
@@ -466,7 +466,7 @@ public ASTFunDecl traverse(final Environment env) {
/*
* Update entry of this function, i.e. set argument references. The entry is already in there by garantuee, but may be
- * of wrong type, i.e. the user defined a function 'TRUE', e.g. and 'TRUE' is of type 'Variable'.
+ * of wrong type, i.e. the user-defined a function 'TRUE', e.g. and 'TRUE' is of type 'Variable'.
*/
try {
final Function fun = (Function) env.get(name.getName());
diff --git a/src/examples/Mini/Environment.java b/src/examples/Mini/Environment.java
index 01e2b7ca2c..59257bfee2 100644
--- a/src/examples/Mini/Environment.java
+++ b/src/examples/Mini/Environment.java
@@ -50,7 +50,7 @@ private static int lookup(final Vector v, final String key) throws Arr
private final int size; // The table is an array of
private final Vector[] table; // Vectors
- private int elements = 0;
+ private int elements;
public Environment() {
this(SIZE);
@@ -112,7 +112,7 @@ public void delete(final String key) {
}
/**
- * Get entry from hash table.
+ * Gets entry from hash table.
*/
public @Nullable EnvEntry get(final String key) {
int hash;
diff --git a/src/examples/Mini/MiniC.java b/src/examples/Mini/MiniC.java
index f58d302403..62e3b9e2ae 100644
--- a/src/examples/Mini/MiniC.java
+++ b/src/examples/Mini/MiniC.java
@@ -28,10 +28,10 @@
import org.apache.bcel.generic.ConstantPoolGen;
public class MiniC {
- private static Vector errors = null;
- private static Vector warnings = null;
- private static String file = null;
- private static int pass = 0;
+ private static Vector errors;
+ private static Vector warnings;
+ private static String file;
+ private static int pass;
final static void addError(final int line, final int column, final String err) {
if (pass != 2) {
diff --git a/src/examples/Mini/MiniParser.java b/src/examples/Mini/MiniParser.java
index 44ba3111c9..cda1588b46 100644
--- a/src/examples/Mini/MiniParser.java
+++ b/src/examples/Mini/MiniParser.java
@@ -28,7 +28,7 @@ private static final class JJCalls {
protected static JJTMiniParserState jjtree = new JJTMiniParserState();
private static Token expr_token;
- static private boolean jj_initialized_once = false;
+ static private boolean jj_initialized_once;
static public MiniParserTokenManager token_source;
@@ -42,7 +42,7 @@ private static final class JJCalls {
static private int jj_la;
- static public boolean lookingAhead = false;
+ static public boolean lookingAhead;
// static private boolean jj_semLA;
static private int jj_gen;
@@ -56,9 +56,9 @@ private static final class JJCalls {
static final private JJCalls[] jj_2_rtns = new JJCalls[1];
- static private boolean jj_rescan = false;
+ static private boolean jj_rescan;
- static private int jj_gc = 0;
+ static private int jj_gc;
static private java.util.Vector jj_expentries = new java.util.Vector<>();
diff --git a/src/examples/Mini/SimpleNode.java b/src/examples/Mini/SimpleNode.java
index fffced768a..b794842cc1 100644
--- a/src/examples/Mini/SimpleNode.java
+++ b/src/examples/Mini/SimpleNode.java
@@ -56,7 +56,7 @@ public void jjtAddChild(final Node n, final int i) {
if (children == null) {
children = new Node[i + 1];
} else if (i >= children.length) {
- final Node c[] = new Node[i + 1];
+ final Node[] c = new Node[i + 1];
System.arraycopy(children, 0, c, 0, children.length);
children = c;
}
diff --git a/src/examples/ProxyCreator.java b/src/examples/ProxyCreator.java
index fcc1572094..2b7d8a9031 100644
--- a/src/examples/ProxyCreator.java
+++ b/src/examples/ProxyCreator.java
@@ -34,7 +34,7 @@
import org.apache.bcel.generic.Type;
/**
- * Dynamically creates and uses a proxy for {@code java.awt.event.ActionListener} via the classloader mechanism if
+ * Dynamically creates and uses a proxy for {@link java.awt.event.ActionListener} via the class loader mechanism if
* called with
*
*
@@ -45,7 +45,7 @@
* however in big ugly class name, so for many cases it will be more sufficient to put some clever creation code into
* the class loader.
*
- * This is comparable to the mechanism provided via {@code java.lang.reflect.Proxy}, but much more flexible.
+ * This is comparable to the mechanism provided via {@link java.lang.reflect.Proxy}, but much more flexible.
*
*
* @see org.apache.bcel.util.JavaWrapper
@@ -60,7 +60,7 @@ public class ProxyCreator {
public static Object createProxy(final String pack, final String className) {
try {
final Class> cl = Class.forName(pack + "$$BCEL$$" + className);
- return cl.newInstance();
+ return cl.getConstructor().newInstance();
} catch (final Exception e) {
e.printStackTrace();
}
diff --git a/src/examples/TransitiveHull.java b/src/examples/TransitiveHull.java
index 5e51a138dc..719eb42921 100644
--- a/src/examples/TransitiveHull.java
+++ b/src/examples/TransitiveHull.java
@@ -133,7 +133,7 @@ public String[] getIgnored() {
}
/**
- * Set the value of ignored.
+ * Sets the value of ignored.
*
* @param v Value to assign to ignored.
*/
diff --git a/src/main/java/org/apache/bcel/Const.java b/src/main/java/org/apache/bcel/Const.java
index 4c805fe6f5..4fca1a4fee 100644
--- a/src/main/java/org/apache/bcel/Const.java
+++ b/src/main/java/org/apache/bcel/Const.java
@@ -36,7 +36,7 @@
public final class Const {
/**
- * Java class file format Magic number (0xCAFEBABE)
+ * Java class file format Magic number: {@value}.
*
* @see The ClassFile Structure
* in The Java Virtual Machine Specification
@@ -44,201 +44,201 @@ public final class Const {
public static final int JVM_CLASSFILE_MAGIC = 0xCAFEBABE;
/**
- * Major version number of class files for Java 1.1.
+ * Major version number of class files for Java 1.1: {@value}.
*
* @see #MINOR_1_1
*/
public static final short MAJOR_1_1 = 45;
/**
- * Minor version number of class files for Java 1.1.
+ * Minor version number of class files for Java 1.1: {@value}.
*
* @see #MAJOR_1_1
*/
public static final short MINOR_1_1 = 3;
/**
- * Major version number of class files for Java 1.2.
+ * Major version number of class files for Java 1.2: {@value}.
*
* @see #MINOR_1_2
*/
public static final short MAJOR_1_2 = 46;
/**
- * Minor version number of class files for Java 1.2.
+ * Minor version number of class files for Java 1.2: {@value}.
*
* @see #MAJOR_1_2
*/
public static final short MINOR_1_2 = 0;
/**
- * Major version number of class files for Java 1.2.
+ * Major version number of class files for Java 1.2: {@value}.
*
* @see #MINOR_1_2
*/
public static final short MAJOR_1_3 = 47;
/**
- * Minor version number of class files for Java 1.3.
+ * Minor version number of class files for Java 1.3: {@value}.
*
* @see #MAJOR_1_3
*/
public static final short MINOR_1_3 = 0;
/**
- * Major version number of class files for Java 1.3.
+ * Major version number of class files for Java 1.3: {@value}.
*
* @see #MINOR_1_3
*/
public static final short MAJOR_1_4 = 48;
/**
- * Minor version number of class files for Java 1.4.
+ * Minor version number of class files for Java 1.4: {@value}.
*
* @see #MAJOR_1_4
*/
public static final short MINOR_1_4 = 0;
/**
- * Major version number of class files for Java 1.4.
+ * Major version number of class files for Java 1.4: {@value}.
*
* @see #MINOR_1_4
*/
public static final short MAJOR_1_5 = 49;
/**
- * Minor version number of class files for Java 1.5.
+ * Minor version number of class files for Java 1.5: {@value}.
*
* @see #MAJOR_1_5
*/
public static final short MINOR_1_5 = 0;
/**
- * Major version number of class files for Java 1.6.
+ * Major version number of class files for Java 1.6: {@value}.
*
* @see #MINOR_1_6
*/
public static final short MAJOR_1_6 = 50;
/**
- * Minor version number of class files for Java 1.6.
+ * Minor version number of class files for Java 1.6: {@value}.
*
* @see #MAJOR_1_6
*/
public static final short MINOR_1_6 = 0;
/**
- * Major version number of class files for Java 1.7.
+ * Major version number of class files for Java 1.7: {@value}.
*
* @see #MINOR_1_7
*/
public static final short MAJOR_1_7 = 51;
/**
- * Minor version number of class files for Java 1.7.
+ * Minor version number of class files for Java 1.7: {@value}.
*
* @see #MAJOR_1_7
*/
public static final short MINOR_1_7 = 0;
/**
- * Major version number of class files for Java 1.8.
+ * Major version number of class files for Java 1.8: {@value}.
*
* @see #MINOR_1_8
*/
public static final short MAJOR_1_8 = 52;
/**
- * Minor version number of class files for Java 1.8.
+ * Minor version number of class files for Java 1.8: {@value}.
*
* @see #MAJOR_1_8
*/
public static final short MINOR_1_8 = 0;
/**
- * Major version number of class files for Java 9.
+ * Major version number of class files for Java 9: {@value}.
*
* @see #MINOR_9
*/
public static final short MAJOR_9 = 53;
/**
- * Minor version number of class files for Java 9.
+ * Minor version number of class files for Java 9: {@value}.
*
* @see #MAJOR_9
*/
public static final short MINOR_9 = 0;
/**
- * @deprecated Use {@link #MAJOR_9} instead
+ * @deprecated Use {@link #MAJOR_9} ({@value}) instead.
*/
@Deprecated
public static final short MAJOR_1_9 = MAJOR_9;
/**
- * @deprecated Use {@link #MINOR_9} instead
+ * @deprecated Use {@link #MINOR_9} ({@value}) instead.
*/
@Deprecated
public static final short MINOR_1_9 = MINOR_9;
/**
- * Major version number of class files for Java 10.
+ * Major version number of class files for Java 10: {@value}.
*
* @see #MINOR_10
*/
public static final short MAJOR_10 = 54;
/**
- * Minor version number of class files for Java 10.
+ * Minor version number of class files for Java 10: {@value}.
*
* @see #MAJOR_10
*/
public static final short MINOR_10 = 0;
/**
- * Major version number of class files for Java 11.
+ * Major version number of class files for Java 11: {@value}.
*
* @see #MINOR_11
*/
public static final short MAJOR_11 = 55;
/**
- * Minor version number of class files for Java 11.
+ * Minor version number of class files for Java 11: {@value}.
*
* @see #MAJOR_11
*/
public static final short MINOR_11 = 0;
/**
- * Major version number of class files for Java 12.
+ * Major version number of class files for Java 12: {@value}.
*
* @see #MINOR_12
*/
public static final short MAJOR_12 = 56;
/**
- * Minor version number of class files for Java 12.
+ * Minor version number of class files for Java 12: {@value}.
*
* @see #MAJOR_12
*/
public static final short MINOR_12 = 0;
/**
- * Major version number of class files for Java 13.
+ * Major version number of class files for Java 13: {@value}.
*
* @see #MINOR_13
*/
public static final short MAJOR_13 = 57;
/**
- * Minor version number of class files for Java 13.
+ * Minor version number of class files for Java 13: {@value}.
*
* @see #MAJOR_13
*/
public static final short MINOR_13 = 0;
/**
- * Minor version number of class files for Java 14.
+ * Minor version number of class files for Java 14: {@value}.
*
* @see #MAJOR_14
* @since 6.4.0
@@ -246,7 +246,7 @@ public final class Const {
public static final short MINOR_14 = 0;
/**
- * Minor version number of class files for Java 15.
+ * Minor version number of class files for Java 15: {@value}.
*
* @see #MAJOR_15
* @since 6.6.0
@@ -254,7 +254,7 @@ public final class Const {
public static final short MINOR_15 = 0;
/**
- * Minor version number of class files for Java 16.
+ * Minor version number of class files for Java 16: {@value}.
*
* @see #MAJOR_16
* @since 6.6.0
@@ -262,7 +262,7 @@ public final class Const {
public static final short MINOR_16 = 0;
/**
- * Minor version number of class files for Java 17.
+ * Minor version number of class files for Java 17: {@value}.
*
* @see #MAJOR_17
* @since 6.6.0
@@ -270,7 +270,7 @@ public final class Const {
public static final short MINOR_17 = 0;
/**
- * Minor version number of class files for Java 18.
+ * Minor version number of class files for Java 18: {@value}.
*
* @see #MAJOR_18
* @since 6.6.0
@@ -278,7 +278,7 @@ public final class Const {
public static final short MINOR_18 = 0;
/**
- * Minor version number of class files for Java 19.
+ * Minor version number of class files for Java 19: {@value}.
*
* @see #MAJOR_19
* @since 6.6.0
@@ -286,7 +286,23 @@ public final class Const {
public static final short MINOR_19 = 0;
/**
- * Major version number of class files for Java 14.
+ * Minor version number of class files for Java 20: {@value}.
+ *
+ * @see #MAJOR_20
+ * @since 6.8.0
+ */
+ public static final short MINOR_20 = 0;
+
+ /**
+ * Minor version number of class files for Java 21: {@value}.
+ *
+ * @see #MAJOR_21
+ * @since 6.8.0
+ */
+ public static final short MINOR_21 = 0;
+
+ /**
+ * Major version number of class files for Java 14: {@value}.
*
* @see #MINOR_14
* @since 6.4.0
@@ -294,7 +310,7 @@ public final class Const {
public static final short MAJOR_14 = 58;
/**
- * Major version number of class files for Java 15.
+ * Major version number of class files for Java 15: {@value}.
*
* @see #MINOR_15
* @since 6.6.0
@@ -302,7 +318,7 @@ public final class Const {
public static final short MAJOR_15 = 59;
/**
- * Major version number of class files for Java 16.
+ * Major version number of class files for Java 16: {@value}.
*
* @see #MINOR_16
* @since 6.6.0
@@ -310,7 +326,7 @@ public final class Const {
public static final short MAJOR_16 = 60;
/**
- * Major version number of class files for Java 17.
+ * Major version number of class files for Java 17: {@value}.
*
* @see #MINOR_17
* @since 6.6.0
@@ -318,7 +334,7 @@ public final class Const {
public static final short MAJOR_17 = 61;
/**
- * Major version number of class files for Java 18.
+ * Major version number of class files for Java 18: {@value}.
*
* @see #MINOR_18
* @since 6.6.0
@@ -326,7 +342,7 @@ public final class Const {
public static final short MAJOR_18 = 62;
/**
- * Major version number of class files for Java 19.
+ * Major version number of class files for Java 19: {@value}.
*
* @see #MINOR_19
* @since 6.6.0
@@ -334,31 +350,47 @@ public final class Const {
public static final short MAJOR_19 = 63;
/**
- * Default major version number. Class file is for Java 1.1.
+ * Major version number of class files for Java 20: {@value}.
+ *
+ * @see #MINOR_20
+ * @since 6.8.0
+ */
+ public static final short MAJOR_20 = 64;
+
+ /**
+ * Major version number of class files for Java 21: {@value}.
+ *
+ * @see #MINOR_21
+ * @since 6.8.0
+ */
+ public static final short MAJOR_21 = 65;
+
+ /**
+ * Default major version number. Class file is for Java 1.1: {@value}.
*
* @see #MAJOR_1_1
*/
public static final short MAJOR = MAJOR_1_1;
/**
- * Default major version number. Class file is for Java 1.1.
+ * Default major version number. Class file is for Java 1.1: {@value}.
*
* @see #MAJOR_1_1
*/
public static final short MINOR = MINOR_1_1;
/**
- * Maximum value for an unsigned short.
+ * Maximum value for an unsigned short: {@value}.
*/
public static final int MAX_SHORT = 65535; // 2^16 - 1
/**
- * Maximum value for an unsigned byte.
+ * Maximum value for an unsigned byte: {@value}.
*/
public static final int MAX_BYTE = 255; // 2^8 - 1
/**
- * One of the access flags for fields, methods, or classes.
+ * One of the access flags for fields, methods, or classes: {@value}.
*
* @see Flag definitions for
* Classes in the Java Virtual Machine Specification (Java SE 9 Edition).
@@ -372,140 +404,140 @@ public final class Const {
public static final short ACC_PUBLIC = 0x0001;
/**
- * One of the access flags for fields, methods, or classes.
+ * One of the access flags for fields, methods, or classes: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_PRIVATE = 0x0002;
/**
- * One of the access flags for fields, methods, or classes.
+ * One of the access flags for fields, methods, or classes: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_PROTECTED = 0x0004;
/**
- * One of the access flags for fields, methods, or classes.
+ * One of the access flags for fields, methods, or classes: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_STATIC = 0x0008;
/**
- * One of the access flags for fields, methods, or classes.
+ * One of the access flags for fields, methods, or classes: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_FINAL = 0x0010;
/**
- * One of the access flags for the Module attribute.
+ * One of the access flags for the Module attribute: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_OPEN = 0x0020;
/**
- * One of the access flags for classes.
+ * One of the access flags for classes: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_SUPER = 0x0020;
/**
- * One of the access flags for methods.
+ * One of the access flags for methods: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_SYNCHRONIZED = 0x0020;
/**
- * One of the access flags for the Module attribute.
+ * One of the access flags for the Module attribute: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_TRANSITIVE = 0x0020;
/**
- * One of the access flags for methods.
+ * One of the access flags for methods: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_BRIDGE = 0x0040;
/**
- * One of the access flags for the Module attribute.
+ * One of the access flags for the Module attribute: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_STATIC_PHASE = 0x0040;
/**
- * One of the access flags for fields.
+ * One of the access flags for fields: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_VOLATILE = 0x0040;
/**
- * One of the access flags for fields.
+ * One of the access flags for fields: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_TRANSIENT = 0x0080;
/**
- * One of the access flags for methods.
+ * One of the access flags for methods: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_VARARGS = 0x0080;
/**
- * One of the access flags for methods.
+ * One of the access flags for methods: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_NATIVE = 0x0100;
/**
- * One of the access flags for classes.
+ * One of the access flags for classes: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_INTERFACE = 0x0200;
/**
- * One of the access flags for methods or classes.
+ * One of the access flags for methods or classes: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_ABSTRACT = 0x0400;
/**
- * One of the access flags for methods.
+ * One of the access flags for methods: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_STRICT = 0x0800;
/**
- * One of the access flags for fields, methods, classes, MethodParameter attribute, or Module attribute.
+ * One of the access flags for fields, methods, classes, MethodParameter attribute, or Module attribute: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_SYNTHETIC = 0x1000;
/**
- * One of the access flags for classes.
+ * One of the access flags for classes: {@value}.
*
* @see #ACC_PUBLIC
*/
public static final short ACC_ANNOTATION = 0x2000;
/**
- * One of the access flags for fields or classes.
+ * One of the access flags for fields or classes: {@value}.
*
* @see #ACC_PUBLIC
*/
@@ -513,7 +545,7 @@ public final class Const {
// Applies to classes compiled by new compilers only
/**
- * One of the access flags for MethodParameter or Module attributes.
+ * One of the access flags for MethodParameter or Module attributes: {@value}.
*
* @see #ACC_PUBLIC
*/
@@ -521,7 +553,7 @@ public final class Const {
public static final @Unsigned short ACC_MANDATED = (short) 0x8000;
/**
- * One of the access flags for classes.
+ * One of the access flags for classes: {@value}.
*
* @see #ACC_PUBLIC
*/
@@ -529,7 +561,7 @@ public final class Const {
public static final @Unsigned short ACC_MODULE = (short) 0x8000;
/**
- * One of the access flags for fields, methods, or classes.
+ * One of the access flags for fields, methods, or classes: {@value}.
*
* @see #ACC_PUBLIC
* @deprecated Use {@link #MAX_ACC_FLAG_I}
@@ -538,7 +570,7 @@ public final class Const {
public static final short MAX_ACC_FLAG = ACC_ENUM;
/**
- * One of the access flags for fields, methods, or classes. ACC_MODULE is negative as a short.
+ * One of the access flags for fields, methods, or classes. ACC_MODULE is negative as a short: {@value}.
*
* @see #ACC_PUBLIC
* @since 6.4.0
@@ -560,7 +592,7 @@ public final class Const {
public static final int ACCESS_NAMES_LENGTH = ACCESS_NAMES.length;
/**
- * Marks a constant pool entry as type UTF-8.
+ * Marks a constant pool entry as type UTF-8: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -573,7 +605,7 @@ public final class Const {
*/
/**
- * Marks a constant pool entry as type Integer.
+ * Marks a constant pool entry as type Integer: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -581,7 +613,7 @@ public final class Const {
public static final byte CONSTANT_Integer = 3;
/**
- * Marks a constant pool entry as type Float.
+ * Marks a constant pool entry as type Float: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -589,7 +621,7 @@ public final class Const {
public static final byte CONSTANT_Float = 4;
/**
- * Marks a constant pool entry as type Long.
+ * Marks a constant pool entry as type Long: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -597,7 +629,7 @@ public final class Const {
public static final byte CONSTANT_Long = 5;
/**
- * Marks a constant pool entry as type Double.
+ * Marks a constant pool entry as type Double: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -605,7 +637,7 @@ public final class Const {
public static final byte CONSTANT_Double = 6;
/**
- * Marks a constant pool entry as a Class
+ * Marks a constant pool entry as a Class: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -613,7 +645,7 @@ public final class Const {
public static final byte CONSTANT_Class = 7;
/**
- * Marks a constant pool entry as a Field Reference.
+ * Marks a constant pool entry as a Field Reference: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -621,7 +653,7 @@ public final class Const {
public static final byte CONSTANT_Fieldref = 9;
/**
- * Marks a constant pool entry as type String
+ * Marks a constant pool entry as type String: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -629,7 +661,7 @@ public final class Const {
public static final byte CONSTANT_String = 8;
/**
- * Marks a constant pool entry as a Method Reference.
+ * Marks a constant pool entry as a Method Reference: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -637,7 +669,7 @@ public final class Const {
public static final byte CONSTANT_Methodref = 10;
/**
- * Marks a constant pool entry as an Interface Method Reference.
+ * Marks a constant pool entry as an Interface Method Reference: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -645,7 +677,7 @@ public final class Const {
public static final byte CONSTANT_InterfaceMethodref = 11;
/**
- * Marks a constant pool entry as a name and type.
+ * Marks a constant pool entry as a name and type: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -653,7 +685,7 @@ public final class Const {
public static final byte CONSTANT_NameAndType = 12;
/**
- * Marks a constant pool entry as a Method Handle.
+ * Marks a constant pool entry as a Method Handle: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -661,7 +693,7 @@ public final class Const {
public static final byte CONSTANT_MethodHandle = 15;
/**
- * Marks a constant pool entry as a Method Type.
+ * Marks a constant pool entry as a Method Type: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -669,16 +701,16 @@ public final class Const {
public static final byte CONSTANT_MethodType = 16;
/**
- * Marks a constant pool entry as dynamically computed.
+ * Marks a constant pool entry as dynamically computed: {@value}.
*
- * @see Change request for JEP
- * 309
+ * @see The Constant Pool in The
+ * Java Virtual Machine Specification
* @since 6.3
*/
public static final byte CONSTANT_Dynamic = 17;
/**
- * Marks a constant pool entry as an Invoke Dynamic
+ * Marks a constant pool entry as an Invoke Dynamic: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -686,7 +718,7 @@ public final class Const {
public static final byte CONSTANT_InvokeDynamic = 18;
/**
- * Marks a constant pool entry as a Module Reference.
+ * Marks a constant pool entry as a Module Reference: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -695,7 +727,7 @@ public final class Const {
public static final byte CONSTANT_Module = 19;
/**
- * Marks a constant pool entry as a Package Reference.
+ * Marks a constant pool entry as a Package Reference: {@value}.
*
* @see The Constant Pool in The
* Java Virtual Machine Specification
@@ -712,23 +744,23 @@ public final class Const {
/**
* The name of the static initializer, also called "class initialization method" or "interface
- * initialization method". This is "<clinit>".
+ * initialization method". This is {@value}.
*/
public static final String STATIC_INITIALIZER_NAME = "";
/**
* The name of every constructor method in a class, also called "instance initialization method". This is
- * "<init>".
+ * {@value}.
*/
public static final String CONSTRUCTOR_NAME = "";
/**
- * The names of the interfaces implemented by arrays
+ * The names of the interfaces implemented by arrays.
*/
private static final @DotSeparatedIdentifiers String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {"java.lang.Cloneable", "java.io.Serializable"};
/**
- * Maximum Constant Pool entries. One of the limitations of the Java Virtual Machine.
+ * Maximum Constant Pool entries: {@value}. One of the limitations of the Java Virtual Machine.
*
* @see The Java Virtual
* Machine Specification, Java SE 8 Edition, page 330, chapter 4.11.
@@ -736,21 +768,25 @@ public final class Const {
public static final int MAX_CP_ENTRIES = 65535;
/**
- * Maximum code size (plus one; the code size must be LESS than this) One of the limitations of the Java Virtual
- * Machine. Note vmspec2 page 152 ("Limitations") says: "The amount of code per non-native, non-abstract method is
- * limited to 65536 bytes by the sizes of the indices in the exception_table of the Code attribute (§4.7.3), in the
- * LineNumberTable attribute (§4.7.8), and in the LocalVariableTable attribute (§4.7.9)." However this should be taken
- * as an upper limit rather than the defined maximum. On page 134 (4.8.1 Static Constants) of the same spec, it says:
- * "The value of the code_length item must be less than 65536." The entry in the Limitations section has been removed
- * from later versions of the spec; it is not present in the Java SE 8 edition.
+ * Maximum code size (plus one; the code size must be LESS than this): {@value}.
+ *
+ * One of the limitations of the Java Virtual Machine. Note vmspec2 page 152 ("Limitations") says:
+ *
+ * "The amount of code per non-native, non-abstract method is limited to 65536 bytes by the sizes of the indices in the exception_table of the Code
+ * attribute (§4.7.3), in the LineNumberTable attribute (§4.7.8), and in the LocalVariableTable attribute (§4.7.9)." However this should be taken as an
+ * upper limit rather than the defined maximum. On page 134 (4.8.1 Static Constants) of the same spec, it says: "The value of the code_length item must be
+ * less than 65536."
+ *
+ * The entry in the Limitations section has been removed from later versions of the specification; it is not present in the Java SE 8 edition.
+ *
*
- * @see The Java Virtual
- * Machine Specification, Java SE 8 Edition, page 104, chapter 4.7.
+ * @see The Java Virtual Machine Specification, Java SE 8
+ * Edition, page 104, chapter 4.7.
*/
public static final int MAX_CODE_SIZE = 65536; // bytes
/**
- * The maximum number of dimensions in an array ({@value}). One of the limitations of the Java Virtual Machine.
+ * The maximum number of dimensions in an array: {@value}. One of the limitations of the Java Virtual Machine.
*
* @see Field Descriptors in
* The Java Virtual Machine Specification
@@ -758,7 +794,7 @@ public final class Const {
public static final int MAX_ARRAY_DIMENSIONS = 255;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -766,7 +802,7 @@ public final class Const {
public static final short NOP = 0;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -774,7 +810,7 @@ public final class Const {
public static final short ACONST_NULL = 1;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -782,7 +818,7 @@ public final class Const {
public static final short ICONST_M1 = 2;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -790,7 +826,7 @@ public final class Const {
public static final short ICONST_0 = 3;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -798,7 +834,7 @@ public final class Const {
public static final short ICONST_1 = 4;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -806,7 +842,7 @@ public final class Const {
public static final short ICONST_2 = 5;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -814,7 +850,7 @@ public final class Const {
public static final short ICONST_3 = 6;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -822,7 +858,7 @@ public final class Const {
public static final short ICONST_4 = 7;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -830,7 +866,7 @@ public final class Const {
public static final short ICONST_5 = 8;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -838,7 +874,7 @@ public final class Const {
public static final short LCONST_0 = 9;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -846,7 +882,7 @@ public final class Const {
public static final short LCONST_1 = 10;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -854,7 +890,7 @@ public final class Const {
public static final short FCONST_0 = 11;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -862,7 +898,7 @@ public final class Const {
public static final short FCONST_1 = 12;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -870,7 +906,7 @@ public final class Const {
public static final short FCONST_2 = 13;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -878,7 +914,7 @@ public final class Const {
public static final short DCONST_0 = 14;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -886,7 +922,7 @@ public final class Const {
public static final short DCONST_1 = 15;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -894,7 +930,7 @@ public final class Const {
public static final short BIPUSH = 16;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -902,7 +938,7 @@ public final class Const {
public static final short SIPUSH = 17;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -910,7 +946,7 @@ public final class Const {
public static final short LDC = 18;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -918,7 +954,7 @@ public final class Const {
public static final short LDC_W = 19;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -926,7 +962,7 @@ public final class Const {
public static final short LDC2_W = 20;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -934,7 +970,7 @@ public final class Const {
public static final short ILOAD = 21;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -942,7 +978,7 @@ public final class Const {
public static final short LLOAD = 22;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -950,7 +986,7 @@ public final class Const {
public static final short FLOAD = 23;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -958,7 +994,7 @@ public final class Const {
public static final short DLOAD = 24;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -966,7 +1002,7 @@ public final class Const {
public static final short ALOAD = 25;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -974,7 +1010,7 @@ public final class Const {
public static final short ILOAD_0 = 26;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -982,7 +1018,7 @@ public final class Const {
public static final short ILOAD_1 = 27;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -990,7 +1026,7 @@ public final class Const {
public static final short ILOAD_2 = 28;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -998,7 +1034,7 @@ public final class Const {
public static final short ILOAD_3 = 29;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1006,7 +1042,7 @@ public final class Const {
public static final short LLOAD_0 = 30;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1014,7 +1050,7 @@ public final class Const {
public static final short LLOAD_1 = 31;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1022,7 +1058,7 @@ public final class Const {
public static final short LLOAD_2 = 32;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1030,7 +1066,7 @@ public final class Const {
public static final short LLOAD_3 = 33;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1038,7 +1074,7 @@ public final class Const {
public static final short FLOAD_0 = 34;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1046,7 +1082,7 @@ public final class Const {
public static final short FLOAD_1 = 35;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1054,7 +1090,7 @@ public final class Const {
public static final short FLOAD_2 = 36;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1062,7 +1098,7 @@ public final class Const {
public static final short FLOAD_3 = 37;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1070,7 +1106,7 @@ public final class Const {
public static final short DLOAD_0 = 38;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1078,7 +1114,7 @@ public final class Const {
public static final short DLOAD_1 = 39;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1086,7 +1122,7 @@ public final class Const {
public static final short DLOAD_2 = 40;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1094,7 +1130,7 @@ public final class Const {
public static final short DLOAD_3 = 41;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1102,7 +1138,7 @@ public final class Const {
public static final short ALOAD_0 = 42;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1110,7 +1146,7 @@ public final class Const {
public static final short ALOAD_1 = 43;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1118,7 +1154,7 @@ public final class Const {
public static final short ALOAD_2 = 44;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1126,7 +1162,7 @@ public final class Const {
public static final short ALOAD_3 = 45;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1134,7 +1170,7 @@ public final class Const {
public static final short IALOAD = 46;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1142,7 +1178,7 @@ public final class Const {
public static final short LALOAD = 47;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1150,7 +1186,7 @@ public final class Const {
public static final short FALOAD = 48;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1158,7 +1194,7 @@ public final class Const {
public static final short DALOAD = 49;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1166,7 +1202,7 @@ public final class Const {
public static final short AALOAD = 50;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1174,7 +1210,7 @@ public final class Const {
public static final short BALOAD = 51;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1182,7 +1218,7 @@ public final class Const {
public static final short CALOAD = 52;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1190,7 +1226,7 @@ public final class Const {
public static final short SALOAD = 53;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1198,7 +1234,7 @@ public final class Const {
public static final short ISTORE = 54;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1206,7 +1242,7 @@ public final class Const {
public static final short LSTORE = 55;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1214,7 +1250,7 @@ public final class Const {
public static final short FSTORE = 56;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1222,7 +1258,7 @@ public final class Const {
public static final short DSTORE = 57;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1230,7 +1266,7 @@ public final class Const {
public static final short ASTORE = 58;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1238,7 +1274,7 @@ public final class Const {
public static final short ISTORE_0 = 59;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1246,7 +1282,7 @@ public final class Const {
public static final short ISTORE_1 = 60;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1254,7 +1290,7 @@ public final class Const {
public static final short ISTORE_2 = 61;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1262,7 +1298,7 @@ public final class Const {
public static final short ISTORE_3 = 62;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1270,7 +1306,7 @@ public final class Const {
public static final short LSTORE_0 = 63;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1278,7 +1314,7 @@ public final class Const {
public static final short LSTORE_1 = 64;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1286,7 +1322,7 @@ public final class Const {
public static final short LSTORE_2 = 65;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1294,7 +1330,7 @@ public final class Const {
public static final short LSTORE_3 = 66;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1302,7 +1338,7 @@ public final class Const {
public static final short FSTORE_0 = 67;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1310,7 +1346,7 @@ public final class Const {
public static final short FSTORE_1 = 68;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1318,7 +1354,7 @@ public final class Const {
public static final short FSTORE_2 = 69;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1326,7 +1362,7 @@ public final class Const {
public static final short FSTORE_3 = 70;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1334,7 +1370,7 @@ public final class Const {
public static final short DSTORE_0 = 71;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1342,7 +1378,7 @@ public final class Const {
public static final short DSTORE_1 = 72;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1350,7 +1386,7 @@ public final class Const {
public static final short DSTORE_2 = 73;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1358,7 +1394,7 @@ public final class Const {
public static final short DSTORE_3 = 74;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1366,7 +1402,7 @@ public final class Const {
public static final short ASTORE_0 = 75;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1374,7 +1410,7 @@ public final class Const {
public static final short ASTORE_1 = 76;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1382,7 +1418,7 @@ public final class Const {
public static final short ASTORE_2 = 77;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -1390,7 +1426,7 @@ public final class Const {
public static final short ASTORE_3 = 78;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1398,7 +1434,7 @@ public final class Const {
public static final short IASTORE = 79;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1406,7 +1442,7 @@ public final class Const {
public static final short LASTORE = 80;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1414,7 +1450,7 @@ public final class Const {
public static final short FASTORE = 81;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1422,7 +1458,7 @@ public final class Const {
public static final short DASTORE = 82;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1430,7 +1466,7 @@ public final class Const {
public static final short AASTORE = 83;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1438,7 +1474,7 @@ public final class Const {
public static final short BASTORE = 84;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1446,7 +1482,7 @@ public final class Const {
public static final short CASTORE = 85;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1454,7 +1490,7 @@ public final class Const {
public static final short SASTORE = 86;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1462,7 +1498,7 @@ public final class Const {
public static final short POP = 87;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1470,7 +1506,7 @@ public final class Const {
public static final short POP2 = 88;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1478,7 +1514,7 @@ public final class Const {
public static final short DUP = 89;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1486,7 +1522,7 @@ public final class Const {
public static final short DUP_X1 = 90;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1494,7 +1530,7 @@ public final class Const {
public static final short DUP_X2 = 91;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1502,7 +1538,7 @@ public final class Const {
public static final short DUP2 = 92;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1510,7 +1546,7 @@ public final class Const {
public static final short DUP2_X1 = 93;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1518,7 +1554,7 @@ public final class Const {
public static final short DUP2_X2 = 94;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1526,7 +1562,7 @@ public final class Const {
public static final short SWAP = 95;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1534,7 +1570,7 @@ public final class Const {
public static final short IADD = 96;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1542,7 +1578,7 @@ public final class Const {
public static final short LADD = 97;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1550,7 +1586,7 @@ public final class Const {
public static final short FADD = 98;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1558,7 +1594,7 @@ public final class Const {
public static final short DADD = 99;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1566,7 +1602,7 @@ public final class Const {
public static final short ISUB = 100;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1574,7 +1610,7 @@ public final class Const {
public static final short LSUB = 101;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1582,7 +1618,7 @@ public final class Const {
public static final short FSUB = 102;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1590,7 +1626,7 @@ public final class Const {
public static final short DSUB = 103;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1598,7 +1634,7 @@ public final class Const {
public static final short IMUL = 104;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1606,7 +1642,7 @@ public final class Const {
public static final short LMUL = 105;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1614,7 +1650,7 @@ public final class Const {
public static final short FMUL = 106;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1622,7 +1658,7 @@ public final class Const {
public static final short DMUL = 107;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1630,7 +1666,7 @@ public final class Const {
public static final short IDIV = 108;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1638,7 +1674,7 @@ public final class Const {
public static final short LDIV = 109;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1646,7 +1682,7 @@ public final class Const {
public static final short FDIV = 110;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1654,7 +1690,7 @@ public final class Const {
public static final short DDIV = 111;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1662,7 +1698,7 @@ public final class Const {
public static final short IREM = 112;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1670,7 +1706,7 @@ public final class Const {
public static final short LREM = 113;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1678,7 +1714,7 @@ public final class Const {
public static final short FREM = 114;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1686,7 +1722,7 @@ public final class Const {
public static final short DREM = 115;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1694,7 +1730,7 @@ public final class Const {
public static final short INEG = 116;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1702,7 +1738,7 @@ public final class Const {
public static final short LNEG = 117;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1710,7 +1746,7 @@ public final class Const {
public static final short FNEG = 118;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1718,7 +1754,7 @@ public final class Const {
public static final short DNEG = 119;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1726,7 +1762,7 @@ public final class Const {
public static final short ISHL = 120;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1734,7 +1770,7 @@ public final class Const {
public static final short LSHL = 121;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1742,7 +1778,7 @@ public final class Const {
public static final short ISHR = 122;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1750,7 +1786,7 @@ public final class Const {
public static final short LSHR = 123;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1758,7 +1794,7 @@ public final class Const {
public static final short IUSHR = 124;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1766,7 +1802,7 @@ public final class Const {
public static final short LUSHR = 125;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1774,7 +1810,7 @@ public final class Const {
public static final short IAND = 126;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1782,7 +1818,7 @@ public final class Const {
public static final short LAND = 127;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1790,7 +1826,7 @@ public final class Const {
public static final short IOR = 128;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1798,7 +1834,7 @@ public final class Const {
public static final short LOR = 129;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1806,7 +1842,7 @@ public final class Const {
public static final short IXOR = 130;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1814,7 +1850,7 @@ public final class Const {
public static final short LXOR = 131;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1822,7 +1858,7 @@ public final class Const {
public static final short IINC = 132;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1830,7 +1866,7 @@ public final class Const {
public static final short I2L = 133;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1838,7 +1874,7 @@ public final class Const {
public static final short I2F = 134;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1846,7 +1882,7 @@ public final class Const {
public static final short I2D = 135;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1854,7 +1890,7 @@ public final class Const {
public static final short L2I = 136;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1862,7 +1898,7 @@ public final class Const {
public static final short L2F = 137;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1870,7 +1906,7 @@ public final class Const {
public static final short L2D = 138;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1878,7 +1914,7 @@ public final class Const {
public static final short F2I = 139;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1886,7 +1922,7 @@ public final class Const {
public static final short F2L = 140;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1894,7 +1930,7 @@ public final class Const {
public static final short F2D = 141;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1902,7 +1938,7 @@ public final class Const {
public static final short D2I = 142;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1910,7 +1946,7 @@ public final class Const {
public static final short D2L = 143;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1918,7 +1954,7 @@ public final class Const {
public static final short D2F = 144;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1926,7 +1962,7 @@ public final class Const {
public static final short I2B = 145;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1934,7 +1970,7 @@ public final class Const {
public static final short INT2BYTE = 145; // Old notation
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1942,7 +1978,7 @@ public final class Const {
public static final short I2C = 146;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1950,7 +1986,7 @@ public final class Const {
public static final short INT2CHAR = 146; // Old notation
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1958,7 +1994,7 @@ public final class Const {
public static final short I2S = 147;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -1966,7 +2002,7 @@ public final class Const {
public static final short INT2SHORT = 147; // Old notation
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1974,7 +2010,7 @@ public final class Const {
public static final short LCMP = 148;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1982,7 +2018,7 @@ public final class Const {
public static final short FCMPL = 149;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1990,7 +2026,7 @@ public final class Const {
public static final short FCMPG = 150;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -1998,7 +2034,7 @@ public final class Const {
public static final short DCMPL = 151;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2006,7 +2042,7 @@ public final class Const {
public static final short DCMPG = 152;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2014,7 +2050,7 @@ public final class Const {
public static final short IFEQ = 153;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2022,7 +2058,7 @@ public final class Const {
public static final short IFNE = 154;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2030,7 +2066,7 @@ public final class Const {
public static final short IFLT = 155;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2038,7 +2074,7 @@ public final class Const {
public static final short IFGE = 156;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2046,7 +2082,7 @@ public final class Const {
public static final short IFGT = 157;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2054,7 +2090,7 @@ public final class Const {
public static final short IFLE = 158;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2062,7 +2098,7 @@ public final class Const {
public static final short IF_ICMPEQ = 159;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2070,7 +2106,7 @@ public final class Const {
public static final short IF_ICMPNE = 160;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2078,7 +2114,7 @@ public final class Const {
public static final short IF_ICMPLT = 161;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2086,7 +2122,7 @@ public final class Const {
public static final short IF_ICMPGE = 162;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2094,7 +2130,7 @@ public final class Const {
public static final short IF_ICMPGT = 163;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2102,7 +2138,7 @@ public final class Const {
public static final short IF_ICMPLE = 164;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2110,7 +2146,7 @@ public final class Const {
public static final short IF_ACMPEQ = 165;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2118,7 +2154,7 @@ public final class Const {
public static final short IF_ACMPNE = 166;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2126,7 +2162,7 @@ public final class Const {
public static final short GOTO = 167;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -2134,7 +2170,7 @@ public final class Const {
public static final short JSR = 168;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -2142,7 +2178,7 @@ public final class Const {
public static final short RET = 169;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2150,7 +2186,7 @@ public final class Const {
public static final short TABLESWITCH = 170;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2158,7 +2194,7 @@ public final class Const {
public static final short LOOKUPSWITCH = 171;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2166,7 +2202,7 @@ public final class Const {
public static final short IRETURN = 172;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2174,7 +2210,7 @@ public final class Const {
public static final short LRETURN = 173;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2182,7 +2218,7 @@ public final class Const {
public static final short FRETURN = 174;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2190,7 +2226,7 @@ public final class Const {
public static final short DRETURN = 175;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2198,7 +2234,7 @@ public final class Const {
public static final short ARETURN = 176;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2206,7 +2242,7 @@ public final class Const {
public static final short RETURN = 177;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -2214,7 +2250,7 @@ public final class Const {
public static final short GETSTATIC = 178;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -2222,7 +2258,7 @@ public final class Const {
public static final short PUTSTATIC = 179;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -2230,7 +2266,7 @@ public final class Const {
public static final short GETFIELD = 180;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -2238,7 +2274,7 @@ public final class Const {
public static final short PUTFIELD = 181;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2246,7 +2282,7 @@ public final class Const {
public static final short INVOKEVIRTUAL = 182;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2254,7 +2290,7 @@ public final class Const {
public static final short INVOKESPECIAL = 183;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -2262,7 +2298,7 @@ public final class Const {
public static final short INVOKENONVIRTUAL = 183; // Old name in JDK 1.0
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2270,7 +2306,7 @@ public final class Const {
public static final short INVOKESTATIC = 184;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2278,7 +2314,7 @@ public final class Const {
public static final short INVOKEINTERFACE = 185;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2286,7 +2322,7 @@ public final class Const {
public static final short INVOKEDYNAMIC = 186;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in The
* Java Virtual Machine Specification
@@ -2294,7 +2330,7 @@ public final class Const {
public static final short NEW = 187;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -2302,7 +2338,7 @@ public final class Const {
public static final short NEWARRAY = 188;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -2310,7 +2346,7 @@ public final class Const {
public static final short ANEWARRAY = 189;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2318,7 +2354,7 @@ public final class Const {
public static final short ARRAYLENGTH = 190;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2326,7 +2362,7 @@ public final class Const {
public static final short ATHROW = 191;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -2334,7 +2370,7 @@ public final class Const {
public static final short CHECKCAST = 192;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -2342,7 +2378,7 @@ public final class Const {
public static final short INSTANCEOF = 193;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2350,7 +2386,7 @@ public final class Const {
public static final short MONITORENTER = 194;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2358,7 +2394,7 @@ public final class Const {
public static final short MONITOREXIT = 195;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2366,7 +2402,7 @@ public final class Const {
public static final short WIDE = 196;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode
* definitions in The Java Virtual Machine Specification
@@ -2374,7 +2410,7 @@ public final class Const {
public static final short MULTIANEWARRAY = 197;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2382,7 +2418,7 @@ public final class Const {
public static final short IFNULL = 198;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions
* in The Java Virtual Machine Specification
@@ -2390,7 +2426,7 @@ public final class Const {
public static final short IFNONNULL = 199;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2398,7 +2434,7 @@ public final class Const {
public static final short GOTO_W = 200;
/**
- * Java VM opcode.
+ * Java VM opcode {@value}.
*
* @see Opcode definitions in
* The Java Virtual Machine Specification
@@ -2406,7 +2442,7 @@ public final class Const {
public static final short JSR_W = 201;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see Reserved opcodes in the Java
* Virtual Machine Specification
@@ -2414,7 +2450,7 @@ public final class Const {
public static final short BREAKPOINT = 202;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2425,7 +2461,7 @@ public final class Const {
public static final short LDC_QUICK = 203;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2436,7 +2472,7 @@ public final class Const {
public static final short LDC_W_QUICK = 204;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2447,7 +2483,7 @@ public final class Const {
public static final short LDC2_W_QUICK = 205;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2458,7 +2494,7 @@ public final class Const {
public static final short GETFIELD_QUICK = 206;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2469,7 +2505,7 @@ public final class Const {
public static final short PUTFIELD_QUICK = 207;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2480,7 +2516,7 @@ public final class Const {
public static final short GETFIELD2_QUICK = 208;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2491,7 +2527,7 @@ public final class Const {
public static final short PUTFIELD2_QUICK = 209;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2502,7 +2538,7 @@ public final class Const {
public static final short GETSTATIC_QUICK = 210;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2513,7 +2549,7 @@ public final class Const {
public static final short PUTSTATIC_QUICK = 211;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2524,7 +2560,7 @@ public final class Const {
public static final short GETSTATIC2_QUICK = 212;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2535,7 +2571,7 @@ public final class Const {
public static final short PUTSTATIC2_QUICK = 213;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2546,7 +2582,7 @@ public final class Const {
public static final short INVOKEVIRTUAL_QUICK = 214;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2557,7 +2593,7 @@ public final class Const {
public static final short INVOKENONVIRTUAL_QUICK = 215;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2568,7 +2604,7 @@ public final class Const {
public static final short INVOKESUPER_QUICK = 216;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2579,7 +2615,7 @@ public final class Const {
public static final short INVOKESTATIC_QUICK = 217;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2590,7 +2626,7 @@ public final class Const {
public static final short INVOKEINTERFACE_QUICK = 218;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2601,7 +2637,7 @@ public final class Const {
public static final short INVOKEVIRTUALOBJECT_QUICK = 219;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2612,7 +2648,7 @@ public final class Const {
public static final short NEW_QUICK = 221;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2623,7 +2659,7 @@ public final class Const {
public static final short ANEWARRAY_QUICK = 222;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2634,7 +2670,7 @@ public final class Const {
public static final short MULTIANEWARRAY_QUICK = 223;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2645,7 +2681,7 @@ public final class Const {
public static final short CHECKCAST_QUICK = 224;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2656,7 +2692,7 @@ public final class Const {
public static final short INSTANCEOF_QUICK = 225;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2667,7 +2703,7 @@ public final class Const {
public static final short INVOKEVIRTUAL_QUICK_W = 226;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2678,7 +2714,7 @@ public final class Const {
public static final short GETFIELD_QUICK_W = 227;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see
@@ -2689,7 +2725,7 @@ public final class Const {
public static final short PUTFIELD_QUICK_W = 228;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see Reserved opcodes in the Java
* Virtual Machine Specification
@@ -2697,7 +2733,7 @@ public final class Const {
public static final short IMPDEP1 = 254;
/**
- * JVM internal opcode.
+ * JVM internal opcode {@value}.
*
* @see Reserved opcodes in the Java
* Virtual Machine Specification
@@ -2705,34 +2741,44 @@ public final class Const {
public static final short IMPDEP2 = 255;
/**
- * BCEL virtual instruction for pushing an arbitrary data type onto the stack. Will be converted to the appropriate JVM
+ * BCEL virtual instruction for pushing an arbitrary data type onto the stack: {@value}. Will be converted to the appropriate JVM
* opcode when the class is dumped.
*/
public static final short PUSH = 4711;
/**
- * BCEL virtual instruction for either LOOKUPSWITCH or TABLESWITCH. Will be converted to the appropriate JVM opcode when
+ * BCEL virtual instruction for either LOOKUPSWITCH or TABLESWITCH: {@value}. Will be converted to the appropriate JVM opcode when
* the class is dumped.
*/
public static final short SWITCH = 4712;
- /** Illegal opcode. */
+ /**
+ * Illegal opcode: {@value}.
+ */
public static final short UNDEFINED = -1;
- /** Illegal opcode. */
+ /**
+ * Illegal opcode: {@value}.
+ */
public static final short UNPREDICTABLE = -2;
- /** Illegal opcode. */
+ /**
+ * Illegal opcode: {@value}.
+ */
public static final short RESERVED = -3;
- /** Mnemonic for an illegal opcode. */
+ /**
+ * Mnemonic for an illegal opcode: {@value}.
+ */
public static final String ILLEGAL_OPCODE = "";
- /** Mnemonic for an illegal type. */
+ /**
+ * Mnemonic for an illegal type: {@value}.
+ */
public static final String ILLEGAL_TYPE = "";
/**
- * Boolean data type.
+ * Boolean data type: {@value}.
*
* @see Static Constraints in
* the Java Virtual Machine Specification
@@ -2740,7 +2786,7 @@ public final class Const {
public static final byte T_BOOLEAN = 4;
/**
- * Char data type.
+ * Char data type: {@value}.
*
* @see Static Constraints in
* the Java Virtual Machine Specification
@@ -2748,7 +2794,7 @@ public final class Const {
public static final byte T_CHAR = 5;
/**
- * Float data type.
+ * Float data type: {@value}.
*
* @see Static Constraints in
* the Java Virtual Machine Specification
@@ -2756,7 +2802,7 @@ public final class Const {
public static final byte T_FLOAT = 6;
/**
- * Double data type.
+ * Double data type: {@value}.
*
* @see Static Constraints in
* the Java Virtual Machine Specification
@@ -2764,7 +2810,7 @@ public final class Const {
public static final byte T_DOUBLE = 7;
/**
- * Byte data type.
+ * Byte data type: {@value}.
*
* @see Static Constraints in
* the Java Virtual Machine Specification
@@ -2772,7 +2818,7 @@ public final class Const {
public static final byte T_BYTE = 8;
/**
- * Short data type.
+ * Short data type: {@value}.
*
* @see Static Constraints in
* the Java Virtual Machine Specification
@@ -2780,7 +2826,7 @@ public final class Const {
public static final byte T_SHORT = 9;
/**
- * Int data type.
+ * Int data type: {@value}.
*
* @see Static Constraints in
* the Java Virtual Machine Specification
@@ -2788,7 +2834,7 @@ public final class Const {
public static final byte T_INT = 10;
/**
- * Long data type.
+ * Long data type: {@value}.
*
* @see Static Constraints in
* the Java Virtual Machine Specification
@@ -2829,7 +2875,7 @@ public final class Const {
/**
* The signature characters corresponding to primitive types, e.g., SHORT_TYPE_NAMES[T_INT] = "I"
*/
- private static final @FieldDescriptor String[] SHORT_TYPE_NAMES = {ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, "Z", "C", "F", "D", "B", "S", "I", "J", "V",
+ public static final @FieldDescriptor String[] SHORT_TYPE_NAMES = {ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, "Z", "C", "F", "D", "B", "S", "I", "J", "V",
ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE};
/**
@@ -3038,6 +3084,7 @@ public final class Const {
public static final byte ATTR_MODULE_MAIN_CLASS = 24;
public static final byte ATTR_NEST_HOST = 25;
public static final byte ATTR_NEST_MEMBERS = 26;
+
public static final short KNOWN_ATTRIBUTES = 27; // count of attributes
private static final String[] ATTRIBUTE_NAMES = {"SourceFile", "ConstantValue", "Code", "Exceptions", "LineNumberTable", "LocalVariableTable",
"InnerClasses", "Synthetic", "Deprecated", "PMGClass", "Signature", "StackMap", "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
@@ -3072,6 +3119,7 @@ public final class Const {
public static final int SAME_FRAME_EXTENDED = 251;
public static final int APPEND_FRAME = 252;
public static final int FULL_FRAME = 255;
+
/**
* Constants that define the maximum value of those constants which store ranges.
*/
@@ -3092,6 +3140,7 @@ public final class Const {
public static final byte REF_invokeSpecial = 7;
public static final byte REF_newInvokeSpecial = 8;
public static final byte REF_invokeInterface = 9;
+
/**
* The names of the reference_kinds of a CONSTANT_MethodHandle_info.
*/
@@ -3099,7 +3148,7 @@ public final class Const {
"newInvokeSpecial", "invokeInterface"};
/**
- * @param index
+ * @param index index into {@code ACCESS_NAMES}.
* @return the ACCESS_NAMES entry at the given index
* @since 6.0
*/
@@ -3110,7 +3159,7 @@ public static String getAccessName(final @NonNegative int index) {
/**
*
- * @param index
+ * @param index index into {@code ACCESS_NAMES}.
* @return the attribute name
* @since 6.0
*/
@@ -3122,7 +3171,7 @@ public static String getAttributeName(final @NonNegative int index) {
/**
* The primitive class names corresponding to the T_XX constants, e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer"
*
- * @param index
+ * @param index index into {@code CLASS_TYPE_NAMES}.
* @return the class name
* @since 6.0
*/
@@ -3133,7 +3182,7 @@ public static String getClassTypeName(final @NonNegative int index) {
/**
*
- * @param index
+ * @param index index into {@code CONSTANT_NAMES}.
* @return the CONSTANT_NAMES entry at the given index
* @since 6.0
*/
@@ -3146,7 +3195,7 @@ public static String getConstantName(final @NonNegative int index) {
/**
*
- * @param index
+ * @param index index into {@code CONSUME_STACK}.
* @return Number of words consumed on operand stack
* @since 6.0
*/
@@ -3164,7 +3213,7 @@ public static int getConsumeStack(final @NonNegative int index) {
/**
*
- * @param index
+ * @param index index into {@code ITEM_NAMES}.
* @return the item name
* @since 6.0
*/
@@ -3175,7 +3224,7 @@ public static String getItemName(final @NonNegative int index) {
/**
*
- * @param index
+ * @param index index into {@code METHODHANDLE_NAMES}.
* @return the method handle name
* @since 6.0
*/
@@ -3186,7 +3235,7 @@ public static String getMethodHandleName(final @NonNegative int index) {
/**
*
- * @param index
+ * @param index index into {@code NO_OF_OPERANDS}.
* @return Number of byte code operands
* @since 6.0
*/
diff --git a/src/main/java/org/apache/bcel/classfile/AccessFlags.java b/src/main/java/org/apache/bcel/classfile/AccessFlags.java
index 105f324428..595b2f27ab 100644
--- a/src/main/java/org/apache/bcel/classfile/AccessFlags.java
+++ b/src/main/java/org/apache/bcel/classfile/AccessFlags.java
@@ -27,22 +27,31 @@
public abstract class AccessFlags {
/**
- * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
+ * Access flags.
+ *
+ * @deprecated (since 6.0) will be made private; do not access directly, use getter/setter.
*/
@java.lang.Deprecated
protected int access_flags; // TODO not used externally at present
+ /**
+ * Constructs a new instance.
+ */
public AccessFlags() {
}
/**
- * @param a initial access flags
+ * Constructs a new instance.
+ *
+ * @param accessFlags initial access flags.
*/
- public AccessFlags(final int a) {
- access_flags = a;
+ public AccessFlags(final int accessFlags) {
+ access_flags = accessFlags;
}
/**
+ * Gets access flags.
+ *
* @return Access flags of the object aka. "modifiers".
*/
@Pure
@@ -51,143 +60,305 @@ public final int getAccessFlags() {
}
/**
- * @return Access flags of the object aka. "modifiers".
+ * Gets access flags.
+ *
+ * @return Access flags of the object also known as modifiers.
*/
@Pure
public final int getModifiers() {
return access_flags;
}
+ /**
+ * Tests whether the abstract bit is on.
+ *
+ * @return whether the abstract bit is on.
+ */
public final boolean isAbstract(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_ABSTRACT) != 0;
+ return test(Const.ACC_ABSTRACT);
}
+ /**
+ * Sets the abstract bit.
+ *
+ * @param flag The new value.
+ */
public final void isAbstract(final boolean flag) {
setFlag(Const.ACC_ABSTRACT, flag);
}
+ /**
+ * Tests whether the annotation bit is on.
+ *
+ * @return whether the annotation bit is on.
+ */
public final boolean isAnnotation(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_ANNOTATION) != 0;
+ return test(Const.ACC_ANNOTATION);
}
+ /**
+ * Sets the annotation bit.
+ *
+ * @param flag The new value.
+ */
public final void isAnnotation(final boolean flag) {
setFlag(Const.ACC_ANNOTATION, flag);
}
+ /**
+ * Tests whether the enum bit is on.
+ *
+ * @return whether the enum bit is on.
+ */
public final boolean isEnum(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_ENUM) != 0;
+ return test(Const.ACC_ENUM);
}
+ /**
+ * Sets the enum bit.
+ *
+ * @param flag The new value.
+ */
public final void isEnum(final boolean flag) {
setFlag(Const.ACC_ENUM, flag);
}
+ /**
+ * Tests whether the final bit is on.
+ *
+ * @return whether the final bit is on.
+ */
public final boolean isFinal(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_FINAL) != 0;
+ return test(Const.ACC_FINAL);
}
+ /**
+ * Sets the final bit.
+ *
+ * @param flag The new value.
+ */
public final void isFinal(final boolean flag) {
setFlag(Const.ACC_FINAL, flag);
}
+ /**
+ * Tests whether the interface bit is on.
+ *
+ * @return whether the interface bit is on.
+ */
public final boolean isInterface(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_INTERFACE) != 0;
+ return test(Const.ACC_INTERFACE);
}
+ /**
+ * Sets the interface bit.
+ *
+ * @param flag The new value.
+ */
public final void isInterface(final boolean flag) {
setFlag(Const.ACC_INTERFACE, flag);
}
+ /**
+ * Tests whether the native bit is on.
+ *
+ * @return whether the native bit is on.
+ */
public final boolean isNative(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_NATIVE) != 0;
+ return test(Const.ACC_NATIVE);
}
+ /**
+ * Sets the native bit.
+ *
+ * @param flag The new value.
+ */
public final void isNative(final boolean flag) {
setFlag(Const.ACC_NATIVE, flag);
}
+ /**
+ * Tests whether the private bit is on.
+ *
+ * @return whether the private bit is on.
+ */
public final boolean isPrivate(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_PRIVATE) != 0;
+ return test(Const.ACC_PRIVATE);
}
+ /**
+ * Sets the private bit.
+ *
+ * @param flag The new value.
+ */
public final void isPrivate(final boolean flag) {
setFlag(Const.ACC_PRIVATE, flag);
}
+ /**
+ * Tests whether the protected bit is on.
+ *
+ * @return whether the protected bit is on.
+ */
public final boolean isProtected(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_PROTECTED) != 0;
+ return test(Const.ACC_PROTECTED);
}
+ /**
+ * Sets the protected bit.
+ *
+ * @param flag The new value.
+ */
public final void isProtected(final boolean flag) {
setFlag(Const.ACC_PROTECTED, flag);
}
+ /**
+ * Tests whether the public bit is on.
+ *
+ * @return whether the public bit is on.
+ */
public final boolean isPublic(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_PUBLIC) != 0;
+ return test(Const.ACC_PUBLIC);
}
+ /**
+ * Sets the public bit.
+ *
+ * @param flag The new value.
+ */
public final void isPublic(final boolean flag) {
setFlag(Const.ACC_PUBLIC, flag);
}
+ /**
+ * Tests whether the static bit is on.
+ *
+ * @return whether the static bit is on.
+ */
public final boolean isStatic(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_STATIC) != 0;
+ return test(Const.ACC_STATIC);
}
+ /**
+ * Sets the static bit.
+ *
+ * @param flag The new value.
+ */
public final void isStatic(final boolean flag) {
setFlag(Const.ACC_STATIC, flag);
}
+ /**
+ * Tests whether the strict bit is on.
+ *
+ * @return whether the strict bit is on.
+ */
public final boolean isStrictfp(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_STRICT) != 0;
+ return test(Const.ACC_STRICT);
}
+ /**
+ * Sets the strict bit.
+ *
+ * @param flag The new value.
+ */
public final void isStrictfp(final boolean flag) {
setFlag(Const.ACC_STRICT, flag);
}
+ /**
+ * Tests whether the synchronized bit is on.
+ *
+ * @return whether the synchronized bit is on.
+ */
public final boolean isSynchronized(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_SYNCHRONIZED) != 0;
+ return test(Const.ACC_SYNCHRONIZED);
}
+ /**
+ * Sets the synchronized bit.
+ *
+ * @param flag The new value.
+ */
public final void isSynchronized(final boolean flag) {
setFlag(Const.ACC_SYNCHRONIZED, flag);
}
+ /**
+ * Tests whether the synthetic bit is on.
+ *
+ * @return whether the synthetic bit is on.
+ */
public final boolean isSynthetic(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_SYNTHETIC) != 0;
+ return test(Const.ACC_SYNTHETIC);
}
+ /**
+ * Sets the synthetic bit.
+ *
+ * @param flag The new value.
+ */
public final void isSynthetic(final boolean flag) {
setFlag(Const.ACC_SYNTHETIC, flag);
}
+ /**
+ * Tests whether the transient bit is on.
+ *
+ * @return whether the varargs bit is on.
+ */
public final boolean isTransient(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_TRANSIENT) != 0;
+ return test(Const.ACC_TRANSIENT);
}
+ /**
+ * Sets the varargs bit.
+ *
+ * @param flag The new value.
+ */
public final void isTransient(final boolean flag) {
setFlag(Const.ACC_TRANSIENT, flag);
}
+ /**
+ * Tests whether the varargs bit is on.
+ *
+ * @return whether the varargs bit is on.
+ */
public final boolean isVarArgs(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_VARARGS) != 0;
+ return test(Const.ACC_VARARGS);
}
+ /**
+ * Sets the varargs bit.
+ *
+ * @param flag The new value.
+ */
public final void isVarArgs(final boolean flag) {
setFlag(Const.ACC_VARARGS, flag);
}
+ /**
+ * Tests whether the volatile bit is on.
+ *
+ * @return whether the volatile bit is on.
+ */
public final boolean isVolatile(@UnknownInitialization(AccessFlags.class) AccessFlags this) {
- return (access_flags & Const.ACC_VOLATILE) != 0;
+ return test(Const.ACC_VOLATILE);
}
+ /**
+ * Sets the volatile bit.
+ *
+ * @param flag The new value.
+ */
public final void isVolatile(final boolean flag) {
setFlag(Const.ACC_VOLATILE, flag);
}
/**
- * Set access flags aka "modifiers".
+ * Sets access flags also known as modifiers.
*
* @param accessFlags Access flags of the object.
*/
@@ -206,11 +377,21 @@ private void setFlag(final int flag, final boolean set) {
}
/**
- * Set access flags aka "modifiers".
+ * Sets access flags aka "modifiers".
*
* @param accessFlags Access flags of the object.
*/
public final void setModifiers(final int accessFlags) {
setAccessFlags(accessFlags);
}
+
+ /**
+ * Tests whether the bit is on.
+ *
+ * @param test the bit to test.
+ * @return whether the bit is on.
+ */
+ private boolean test(final short test) {
+ return (access_flags & test) != 0;
+ }
}
diff --git a/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java b/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
index 40352ef2b5..d74a54c98b 100644
--- a/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
+++ b/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
@@ -55,7 +55,6 @@ public static AnnotationEntry[] createAnnotationEntries(final Attribute[] attrs)
public static AnnotationEntry read(final DataInput input, final ConstantPool constantPool, final boolean isRuntimeVisible) throws IOException {
final AnnotationEntry annotationEntry = new AnnotationEntry(input.readUnsignedShort(), constantPool, isRuntimeVisible);
final int numElementValuePairs = input.readUnsignedShort();
- annotationEntry.elementValuePairs = new ArrayList<>();
for (int i = 0; i < numElementValuePairs; i++) {
annotationEntry.elementValuePairs
.add(new ElementValuePair(input.readUnsignedShort(), ElementValue.readElementValue(input, constantPool), constantPool));
@@ -69,12 +68,13 @@ public static AnnotationEntry read(final DataInput input, final ConstantPool con
private final boolean isRuntimeVisible;
- private List elementValuePairs;
+ private final List elementValuePairs;
public AnnotationEntry(final @NonNegative int typeIndex, final ConstantPool constantPool, final boolean isRuntimeVisible) {
this.typeIndex = typeIndex;
this.constantPool = constantPool;
this.isRuntimeVisible = isRuntimeVisible;
+ this.elementValuePairs = new ArrayList<>();
}
/**
diff --git a/src/main/java/org/apache/bcel/classfile/Attribute.java b/src/main/java/org/apache/bcel/classfile/Attribute.java
index 79c2b46fa1..4bfebbb835 100644
--- a/src/main/java/org/apache/bcel/classfile/Attribute.java
+++ b/src/main/java/org/apache/bcel/classfile/Attribute.java
@@ -294,7 +294,7 @@ public Object clone() {
try {
attr = (Attribute) super.clone();
} catch (final CloneNotSupportedException e) {
- throw new Error("Clone Not Supported"); // never happens
+ throw new UnsupportedOperationException("Clone Not Supported", e); // never happens
}
return attr;
}
diff --git a/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java b/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java
index 3b6d8b712d..e7e664317b 100644
--- a/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java
+++ b/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java
@@ -55,7 +55,7 @@ public BootstrapMethod(final BootstrapMethod c) {
}
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param input Input stream
* @throws IOException if an I/O error occurs.
diff --git a/src/main/java/org/apache/bcel/classfile/BootstrapMethods.java b/src/main/java/org/apache/bcel/classfile/BootstrapMethods.java
index 1a699c5f47..3394e02eea 100644
--- a/src/main/java/org/apache/bcel/classfile/BootstrapMethods.java
+++ b/src/main/java/org/apache/bcel/classfile/BootstrapMethods.java
@@ -62,7 +62,7 @@ public BootstrapMethods(final @NonNegative int nameIndex, final @NonNegative int
}
/**
- * Construct object from Input stream.
+ * Constructs object from Input stream.
*
* @param nameIndex Index in constant pool to CONSTANT_Utf8
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/ClassFormatException.java b/src/main/java/org/apache/bcel/classfile/ClassFormatException.java
index 1816f623a2..2023c849f1 100644
--- a/src/main/java/org/apache/bcel/classfile/ClassFormatException.java
+++ b/src/main/java/org/apache/bcel/classfile/ClassFormatException.java
@@ -42,12 +42,10 @@ public ClassFormatException(final String message) {
/**
* Constructs a new instance with the specified detail message and cause.
- *
- * Note that the detail message associated with {@code cause} is not automatically incorporated in this runtime exception's detail message.
*
* @param message the detail message (which is saved for later retrieval by the {@link #getMessage()} method).
- * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that
- * the cause is nonexistent or unknown.)
+ * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). A {@code null} value is permitted, and indicates that
+ * the cause is nonexistent or unknown.
* @since 6.0
*/
public ClassFormatException(final String message, final Throwable cause) {
@@ -58,8 +56,8 @@ public ClassFormatException(final String message, final Throwable cause) {
* Constructs a new instance with the specified cause and a detail message of {@code (cause==null ? null : cause.toString())} (which typically contains the
* class and detail message of {@code cause}). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
*
- * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the
- * cause is nonexistent or unknown.)
+ * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). A {@code null} value is permitted, and indicates that the
+ * cause is nonexistent or unknown.
* @since 6.7.0
*/
public ClassFormatException(final Throwable cause) {
diff --git a/src/main/java/org/apache/bcel/classfile/ClassParser.java b/src/main/java/org/apache/bcel/classfile/ClassParser.java
index 149d6dd661..c11f94a76d 100644
--- a/src/main/java/org/apache/bcel/classfile/ClassParser.java
+++ b/src/main/java/org/apache/bcel/classfile/ClassParser.java
@@ -60,7 +60,7 @@ public final class ClassParser {
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
- private final boolean isZip; // Loaded from zip file
+ private final boolean isZip; // Loaded from ZIP file
/**
* Parses class from the given stream.
@@ -94,7 +94,7 @@ public ClassParser(final String fileName) {
/**
* Parses class from given .class file in a ZIP-archive
*
- * @param zipFile zip file name
+ * @param zipFile ZIP file name
* @param fileName file name
*/
public ClassParser(final String zipFile, final String fileName) {
@@ -107,7 +107,7 @@ public ClassParser(final String zipFile, final String fileName) {
/**
* Parses the given Java class file and return an object that represents the contained data, i.e., constants, methods,
* fields and commands. A ClassFormatException is raised, if the file is not a valid .class file. (This does
- * not include verification of the byte code as it is performed by the java interpreter).
+ * not include verification of the byte code as it is performed by the Java interpreter).
*
* @return Class object representing the parsed class file
* @throws IOException if an I/O error occurs.
diff --git a/src/main/java/org/apache/bcel/classfile/Code.java b/src/main/java/org/apache/bcel/classfile/Code.java
index e4b068572f..6790b12d5c 100644
--- a/src/main/java/org/apache/bcel/classfile/Code.java
+++ b/src/main/java/org/apache/bcel/classfile/Code.java
@@ -282,6 +282,20 @@ public CodeException[] getExceptionTable() {
return maxStack;
}
+ /**
+ * Finds the attribute of {@link StackMap} instance.
+ * @return StackMap of Code, if it has one, else null.
+ * @since 6.8.0
+ */
+ public StackMap getStackMap() {
+ for (final Attribute attribute : attributes) {
+ if (attribute instanceof StackMap) {
+ return (StackMap) attribute;
+ }
+ }
+ return null;
+ }
+
/**
* @param attributes the attributes to set for this Code
*/
diff --git a/src/main/java/org/apache/bcel/classfile/CodeException.java b/src/main/java/org/apache/bcel/classfile/CodeException.java
index cb41466c63..a6ae8e545b 100644
--- a/src/main/java/org/apache/bcel/classfile/CodeException.java
+++ b/src/main/java/org/apache/bcel/classfile/CodeException.java
@@ -62,10 +62,10 @@ public final class CodeException implements Cloneable, Node, Constants {
*/
static final CodeException[] EMPTY_CODE_EXCEPTION_ARRAY = {};
- /** Range in the code the exception handler is active. */
+ /** Range in the code the exception handler. */
private @NonNegative int startPc;
- /** startPc is inclusive, endPc exclusive. */
+ /** Active. startPc is inclusive, endPc exclusive. */
private @NonNegative int endPc;
/**
diff --git a/src/main/java/org/apache/bcel/classfile/Constant.java b/src/main/java/org/apache/bcel/classfile/Constant.java
index 753e1418e5..72044d3da1 100644
--- a/src/main/java/org/apache/bcel/classfile/Constant.java
+++ b/src/main/java/org/apache/bcel/classfile/Constant.java
@@ -33,27 +33,24 @@
*/
public abstract class Constant implements Cloneable, Node {
- private static BCELComparator bcelComparator = new BCELComparator() {
+ private static BCELComparator bcelComparator = new BCELComparator() {
@Override
- public boolean equals(final Object o1, final Object o2) {
- final Constant THIS = (Constant) o1;
- final Constant THAT = (Constant) o2;
- return Objects.equals(THIS.toString(), THAT.toString());
+ public boolean equals(final Constant a, final Constant b) {
+ return a == b || a != null && b != null && Objects.equals(a.toString(), b.toString());
}
@Override
- public int hashCode(final Object o) {
- final Constant THIS = (Constant) o;
- return THIS.toString().hashCode();
+ public int hashCode(final Constant o) {
+ return o != null ? Objects.hashCode(o.toString()) : 0;
}
};
/**
- * @return Comparison strategy object
+ * @return Comparison strategy object.
*/
@Pure
- public static BCELComparator getComparator() {
+ public static BCELComparator getComparator() {
return bcelComparator;
}
@@ -111,7 +108,7 @@ public static Constant readConstant(final DataInput dataInput) throws IOExceptio
/**
* @param comparator Comparison strategy object
*/
- public static void setComparator(final BCELComparator comparator) {
+ public static void setComparator(final BCELComparator comparator) {
bcelComparator = comparator;
}
@@ -146,7 +143,7 @@ public Object clone() {
try {
return super.clone();
} catch (final CloneNotSupportedException e) {
- throw new Error("Clone Not Supported"); // never happens
+ throw new UnsupportedOperationException("Clone Not Supported", e); // never happens
}
}
@@ -173,7 +170,7 @@ public Constant copy() {
*/
@Override
public boolean equals(final @Nullable Object obj) {
- return bcelComparator.equals(this, obj);
+ return obj instanceof Constant && bcelComparator.equals(this, (Constant) obj);
}
/**
diff --git a/src/main/java/org/apache/bcel/classfile/ConstantObject.java b/src/main/java/org/apache/bcel/classfile/ConstantObject.java
index e15699f03e..64ae7cd950 100644
--- a/src/main/java/org/apache/bcel/classfile/ConstantObject.java
+++ b/src/main/java/org/apache/bcel/classfile/ConstantObject.java
@@ -24,7 +24,10 @@
public interface ConstantObject {
/**
- * @return object representing the constant, e.g., Long for ConstantLong
+ * Gets the object representing the constant, e.g., Long for ConstantLong.
+ *
+ * @param constantPool the constant.
+ * @return object representing the constant, e.g., Long for ConstantLong.
*/
- Object getConstantValue(ConstantPool cp);
+ Object getConstantValue(ConstantPool constantPool);
}
diff --git a/src/main/java/org/apache/bcel/classfile/ConstantPool.java b/src/main/java/org/apache/bcel/classfile/ConstantPool.java
index b7d618478f..8f69a057f9 100644
--- a/src/main/java/org/apache/bcel/classfile/ConstantPool.java
+++ b/src/main/java/org/apache/bcel/classfile/ConstantPool.java
@@ -89,6 +89,7 @@ public ConstantPool(final DataInput input) throws IOException {
constantPool = new Constant[constantPoolCount];
/*
* constantPool[0] is unused by the compiler and may be used freely by the implementation.
+ * constantPool[0] is currently unused by the implementation.
*/
for (int i = 1; i < constantPoolCount; i++) {
constantPool[i] = Constant.readConstant(input);
@@ -289,7 +290,7 @@ public T getConstant(final @NonNegative int index, final by
*/
public T getConstant(final @NonNegative int index, final byte tag, final Class castTo) throws ClassFormatException {
final T c = getConstant(index);
- if (c.getTag() != tag) {
+ if (c == null || c.getTag() != tag) {
throw new ClassFormatException("Expected class '" + Const.getConstantName(tag) + "' at index " + index + " and got " + c);
}
return c;
@@ -307,23 +308,25 @@ public T getConstant(final @NonNegative int index, final by
* @since 6.6.0
*/
public T getConstant(final @NonNegative int index, final Class castTo) throws ClassFormatException {
- if (index >= constantPool.length || index < 0) {
+ if (index >= constantPool.length || index < 1) {
throw new ClassFormatException("Invalid constant pool reference using index: " + index + ". Constant pool size is: " + constantPool.length);
}
if (constantPool[index] != null && !castTo.isAssignableFrom(constantPool[index].getClass())) {
throw new ClassFormatException("Invalid constant pool reference at index: " + index +
". Expected " + castTo + " but was " + constantPool[index].getClass());
}
+ if (index > 1) {
+ final Constant prev = constantPool[index - 1];
+ if (prev != null && (prev.getTag() == Const.CONSTANT_Double || prev.getTag() == Const.CONSTANT_Long)) {
+ throw new ClassFormatException("Constant pool at index " + index + " is invalid. The index is unused due to the preceeding "
+ + Const.getConstantName(prev.getTag()) + ".");
+ }
+ }
// Previous check ensures this won't throw a ClassCastException
final T c = castTo.cast(constantPool[index]);
- if (c == null
- // the 0th element is always null
- && index != 0) {
- final Constant prev = constantPool[index - 1];
- if (prev == null || prev.getTag() != Const.CONSTANT_Double && prev.getTag() != Const.CONSTANT_Long) {
+ if (c == null) {
throw new ClassFormatException("Constant pool at index " + index + " is null.");
}
- }
return c;
}
diff --git a/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java b/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java
index f04f0a937e..2f24276e64 100644
--- a/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java
+++ b/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java
@@ -34,11 +34,11 @@
* The following system properties govern caching this class performs.
*
*
- * - {@value #SYS_PROP_CACHE_MAX_ENTRIES} (since 6.4): The size of the cache, by default 0, meaning caching is
+ *
- {@link #SYS_PROP_CACHE_MAX_ENTRIES} (since 6.4): The size of the cache, by default 0, meaning caching is
* disabled.
- * - {@value #SYS_PROP_CACHE_MAX_ENTRY_SIZE} (since 6.0): The maximum size of the values to cache, by default 200, 0
+ *
- {@link #SYS_PROP_CACHE_MAX_ENTRY_SIZE} (since 6.0): The maximum size of the values to cache, by default 200, 0
* disables caching. Values larger than this are not cached.
- * - {@value #SYS_PROP_STATISTICS} (since 6.0): Prints statistics on the console when the JVM exits.
+ * - {@link #SYS_PROP_STATISTICS} (since 6.0): Prints statistics on the console when the JVM exits.
*
*
* Here is a sample Maven invocation with caching disabled:
@@ -59,7 +59,7 @@
*/
public final class ConstantUtf8 extends Constant {
- private static class Cache {
+ private static final class Cache {
private static final boolean BCEL_STATISTICS = Boolean.getBoolean(SYS_PROP_STATISTICS);
private static final int MAX_ENTRIES = Integer.getInteger(SYS_PROP_CACHE_MAX_ENTRIES, 0).intValue();
@@ -115,6 +115,11 @@ static synchronized void clearStats() {
hits = considered = skipped = created = 0;
}
+ // Avoid Spotbugs complaint about Write to static field
+ private static void countCreated() {
+ created++;
+ }
+
/**
* Gets a new or cached instance of the given value.
*
@@ -201,7 +206,7 @@ public ConstantUtf8(final ConstantUtf8 constantUtf8) {
ConstantUtf8(final DataInput dataInput) throws IOException {
super(Const.CONSTANT_Utf8);
value = dataInput.readUTF();
- created++;
+ countCreated();
}
/**
@@ -210,7 +215,7 @@ public ConstantUtf8(final ConstantUtf8 constantUtf8) {
public ConstantUtf8(final String value) {
super(Const.CONSTANT_Utf8);
this.value = Objects.requireNonNull(value, "value");
- created++;
+ countCreated();
}
/**
diff --git a/src/main/java/org/apache/bcel/classfile/ConstantValue.java b/src/main/java/org/apache/bcel/classfile/ConstantValue.java
index 591a2aa456..61ed5407e5 100644
--- a/src/main/java/org/apache/bcel/classfile/ConstantValue.java
+++ b/src/main/java/org/apache/bcel/classfile/ConstantValue.java
@@ -56,7 +56,7 @@ public ConstantValue(final ConstantValue c) {
}
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Name index in constant pool
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/Deprecated.java b/src/main/java/org/apache/bcel/classfile/Deprecated.java
index 34b5204a49..370fb51132 100644
--- a/src/main/java/org/apache/bcel/classfile/Deprecated.java
+++ b/src/main/java/org/apache/bcel/classfile/Deprecated.java
@@ -61,7 +61,7 @@ public Deprecated(final @NonNegative int nameIndex, final @NonNegative int lengt
}
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index in constant pool to CONSTANT_Utf8
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/DescendingVisitor.java b/src/main/java/org/apache/bcel/classfile/DescendingVisitor.java
index 59fe19abe7..c5421f1e5a 100644
--- a/src/main/java/org/apache/bcel/classfile/DescendingVisitor.java
+++ b/src/main/java/org/apache/bcel/classfile/DescendingVisitor.java
@@ -527,6 +527,20 @@ public void visitStackMap(final StackMap table) {
@Override
public void visitStackMapEntry(final StackMapEntry var) {
+ stack.push(var);
+ var.accept(visitor);
+ accept(var.getTypesOfLocals());
+ accept(var.getTypesOfStackItems());
+ stack.pop();
+ }
+
+ /**
+ * Visits a {@link StackMapType} object.
+ * @param var object to visit
+ * @since 6.8.0
+ */
+ @Override
+ public void visitStackMapType(final StackMapType var) {
stack.push(var);
var.accept(visitor);
stack.pop();
diff --git a/src/main/java/org/apache/bcel/classfile/EmptyVisitor.java b/src/main/java/org/apache/bcel/classfile/EmptyVisitor.java
index b817ad9fd6..5eaaa968e9 100644
--- a/src/main/java/org/apache/bcel/classfile/EmptyVisitor.java
+++ b/src/main/java/org/apache/bcel/classfile/EmptyVisitor.java
@@ -310,6 +310,15 @@ public void visitStackMap(final StackMap obj) {
public void visitStackMapEntry(final StackMapEntry obj) {
}
+ /**
+ * Visits a {@link StackMapType} object.
+ * @param obj object to visit
+ * @since 6.8.0
+ */
+ @Override
+ public void visitStackMapType(final StackMapType obj) {
+ }
+
@Override
public void visitSynthetic(final Synthetic obj) {
}
diff --git a/src/main/java/org/apache/bcel/classfile/ExceptionTable.java b/src/main/java/org/apache/bcel/classfile/ExceptionTable.java
index 135f6a1fc6..fa0c7d2571 100644
--- a/src/main/java/org/apache/bcel/classfile/ExceptionTable.java
+++ b/src/main/java/org/apache/bcel/classfile/ExceptionTable.java
@@ -62,7 +62,7 @@ public ExceptionTable(final ExceptionTable c) {
}
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index in constant pool
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/Field.java b/src/main/java/org/apache/bcel/classfile/Field.java
index 755fbbd3de..a3c1db9643 100644
--- a/src/main/java/org/apache/bcel/classfile/Field.java
+++ b/src/main/java/org/apache/bcel/classfile/Field.java
@@ -43,19 +43,16 @@ public final class Field extends FieldOrMethod {
*/
public static final Field[] EMPTY_ARRAY = {};
- private static BCELComparator bcelComparator = new BCELComparator() {
+ private static BCELComparator bcelComparator = new BCELComparator() {
@Override
- public boolean equals(final Object o1, final Object o2) {
- final Field THIS = (Field) o1;
- final Field THAT = (Field) o2;
- return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature());
+ public boolean equals(final Field a, final Field b) {
+ return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
- public int hashCode(final Object o) {
- final Field THIS = (Field) o;
- return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
+ public int hashCode(final Field o) {
+ return o != null ? Objects.hash(o.getSignature(), o.getName()) : 0;
}
};
@@ -65,24 +62,24 @@ public int hashCode(final Object o) {
static final Field[] EMPTY_FIELD_ARRAY = {};
/**
- * @return Comparison strategy object
+ * @return Comparison strategy object.
*/
@Pure
- public static BCELComparator getComparator() {
+ public static BCELComparator getComparator() {
return bcelComparator;
}
/**
- * @param comparator Comparison strategy object
+ * @param comparator Comparison strategy object.
*/
- public static void setComparator(final BCELComparator comparator) {
+ public static void setComparator(final BCELComparator comparator) {
bcelComparator = comparator;
}
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
- * @param file Input stream
+ * @param file Input stream.
*/
Field(final DataInput file, final ConstantPool constantPool) throws IOException, ClassFormatException {
super(file, constantPool);
@@ -136,7 +133,7 @@ public Field copy(final ConstantPool constantPool) {
@Override
@SuppressWarnings("nullness") // BCEL bug: equals() crashes when passed null
public boolean equals(final @Nullable Object obj) {
- return bcelComparator.equals(this, obj);
+ return obj instanceof Field && bcelComparator.equals(this, (Field) obj);
}
/**
@@ -153,10 +150,12 @@ public boolean equals(final @Nullable Object obj) {
}
/**
+ * See https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.2.2
+ *
* @return type of field
*/
public Type getType() {
- return Type.getReturnType(getSignature());
+ return Type.getType(getSignature());
}
/**
diff --git a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java
index 137b6e157f..8609e6e9ba 100644
--- a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java
+++ b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java
@@ -72,7 +72,7 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
}
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param file Input stream
* @throws IOException if an I/O error occurs.
@@ -88,7 +88,7 @@ protected FieldOrMethod(final DataInput file, final ConstantPool constantPool) t
}
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param file Input stream
* @throws IOException if an I/O error occurs.
@@ -137,7 +137,7 @@ protected FieldOrMethod copy_(final ConstantPool constantPool) {
Arrays.setAll(c.attributes, i -> attributes[i].copy(constantPool));
return c;
} catch (final CloneNotSupportedException e) {
- throw new IllegalStateException(e);
+ throw new UnsupportedOperationException(e);
}
}
@@ -225,7 +225,7 @@ public final String getName() {
}
/**
- * @return String representation of object's type signature (java style)
+ * @return String representation of object's type signature (Java style)
*/
public final String getSignature() {
return constant_pool.getConstantUtf8(signature_index).getBytes();
diff --git a/src/main/java/org/apache/bcel/classfile/InnerClass.java b/src/main/java/org/apache/bcel/classfile/InnerClass.java
index cfb7f19170..336fb50a3f 100644
--- a/src/main/java/org/apache/bcel/classfile/InnerClass.java
+++ b/src/main/java/org/apache/bcel/classfile/InnerClass.java
@@ -41,7 +41,7 @@ public final class InnerClass implements Cloneable, Node {
private int innerAccessFlags;
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param file Input stream
* @throws IOException if an I/O error occurs.
diff --git a/src/main/java/org/apache/bcel/classfile/InnerClasses.java b/src/main/java/org/apache/bcel/classfile/InnerClasses.java
index fa7b94ac12..1096fbe624 100644
--- a/src/main/java/org/apache/bcel/classfile/InnerClasses.java
+++ b/src/main/java/org/apache/bcel/classfile/InnerClasses.java
@@ -58,7 +58,7 @@ public InnerClasses(final InnerClasses c) {
}
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index in constant pool to CONSTANT_Utf8
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/InvalidMethodSignatureException.java b/src/main/java/org/apache/bcel/classfile/InvalidMethodSignatureException.java
new file mode 100644
index 0000000000..5e5b382339
--- /dev/null
+++ b/src/main/java/org/apache/bcel/classfile/InvalidMethodSignatureException.java
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+/**
+ * Thrown when the BCEL attempts to read a class file and determines that a class is malformed or otherwise cannot be interpreted as a class file.
+ *
+ * @since 6.8.0
+ */
+public class InvalidMethodSignatureException extends ClassFormatException {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructs a new instance with the specified invalid signature as the message.
+ *
+ * @param signature The invalid signature is saved for later retrieval by the {@link #getMessage()} method.
+ */
+ public InvalidMethodSignatureException(final String signature) {
+ super(signature);
+ }
+
+ /**
+ * Constructs a new instance with the specified invalid signature as the message and a cause.
+ *
+ * @param signature The invalid signature is saved for later retrieval by the {@link #getMessage()} method.
+ * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). A {@code null} value is permitted, and indicates that
+ * the cause is nonexistent or unknown.
+ */
+ public InvalidMethodSignatureException(final String signature, final Throwable cause) {
+ super(signature, cause);
+ }
+
+}
diff --git a/src/main/java/org/apache/bcel/classfile/JavaClass.java b/src/main/java/org/apache/bcel/classfile/JavaClass.java
index 423b2fe001..398bca30b1 100644
--- a/src/main/java/org/apache/bcel/classfile/JavaClass.java
+++ b/src/main/java/org/apache/bcel/classfile/JavaClass.java
@@ -74,19 +74,17 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
public static final byte FILE = 2;
public static final byte ZIP = 3;
private static final boolean debug = Boolean.getBoolean("JavaClass.debug"); // Debugging on/off
- private static BCELComparator bcelComparator = new BCELComparator() {
+
+ private static BCELComparator bcelComparator = new BCELComparator() {
@Override
- public boolean equals(final Object o1, final Object o2) {
- final JavaClass THIS = (JavaClass) o1;
- final JavaClass THAT = (JavaClass) o2;
- return Objects.equals(THIS.getClassName(), THAT.getClassName());
+ public boolean equals(final JavaClass a, final JavaClass b) {
+ return a == b || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
}
@Override
- public int hashCode(final Object o) {
- final JavaClass THIS = (JavaClass) o;
- return THIS.getClassName().hashCode();
+ public int hashCode(final JavaClass o) {
+ return o != null ? Objects.hashCode(o.getClassName()) : 0;
}
};
@@ -100,10 +98,10 @@ static void Debug(final String str) {
}
/**
- * @return Comparison strategy object
+ * @return Comparison strategy object.
*/
@Pure
- public static BCELComparator getComparator() {
+ public static BCELComparator getComparator() {
return bcelComparator;
}
@@ -117,9 +115,9 @@ private static String indent(final Object obj) {
}
/**
- * @param comparator Comparison strategy object
+ * @param comparator Comparison strategy object.
*/
- public static void setComparator(final BCELComparator comparator) {
+ public static void setComparator(final BCELComparator comparator) {
bcelComparator = comparator;
}
@@ -402,11 +400,51 @@ public void dump(final String fileName) throws IOException {
*/
@Override
public boolean equals(final @Nullable Object obj) {
- return bcelComparator.equals(this, obj);
+ return obj instanceof JavaClass && bcelComparator.equals(this, (JavaClass) obj);
+ }
+
+ /**
+ * Finds a visible field by name and type in this class and its super classes.
+ * @param fieldName the field name to find
+ * @param fieldType the field type to find
+ * @return field matching given name and type, null if field is not found or not accessible from this class.
+ * @throws ClassNotFoundException
+ * @since 6.8.0
+ */
+ public Field findField(final String fieldName, final Type fieldType) throws ClassNotFoundException {
+ for (final Field field : fields) {
+ if (field.getName().equals(fieldName)) {
+ final Type fType = Type.getType(field.getSignature());
+ /*
+ * TODO: Check if assignment compatibility is sufficient. What does Sun do?
+ */
+ if (fType.equals(fieldType)) {
+ return field;
+ }
+ }
+ }
+
+ final JavaClass superclass = getSuperClass();
+ if (superclass != null && !"java.lang.Object".equals(superclass.getClassName())) {
+ final Field f = superclass.findField(fieldName, fieldType);
+ if (f != null && (f.isPublic() || f.isProtected() || !f.isPrivate() && packageName.equals(superclass.getPackageName()))) {
+ return f;
+ }
+ }
+ final JavaClass[] implementedInterfaces = getInterfaces();
+ if (implementedInterfaces != null) {
+ for (final JavaClass implementedInterface : implementedInterfaces) {
+ final Field f = implementedInterface.findField(fieldName, fieldType);
+ if (f != null) {
+ return f;
+ }
+ }
+ }
+ return null;
}
/**
- * Get all interfaces implemented by this JavaClass (transitively).
+ * Gets all interfaces implemented by this JavaClass (transitively).
*
* @throws ClassNotFoundException if any of the class's superclasses or interfaces can't be found.
*/
@@ -522,7 +560,7 @@ public int[] getInterfaceIndices() {
}
/**
- * Get interfaces directly implemented by this JavaClass.
+ * Gets interfaces directly implemented by this JavaClass.
*
* @throws ClassNotFoundException if any of the class's interfaces can't be found.
*/
@@ -622,7 +660,7 @@ public String getSourceFilePath() {
}
/**
- * @return the superclass for this JavaClass object, or null if this is java.lang.Object
+ * @return the superclass for this JavaClass object, or null if this is {@link Object}
* @throws ClassNotFoundException if the superclass can't be found
*/
public @Nullable JavaClass getSuperClass() throws ClassNotFoundException {
@@ -646,8 +684,8 @@ public JavaClass[] getSuperClasses() throws ClassNotFoundException {
}
/**
- * returns the super class name of this class. In the case that this class is java.lang.Object, it will return itself
- * (java.lang.Object). This is probably incorrect but isn't fixed at this time to not break existing clients.
+ * returns the super class name of this class. In the case that this class is {@link Object}, it will return itself
+ * ({@link Object}). This is probably incorrect but isn't fixed at this time to not break existing clients.
*
* @return Superclass name.
*/
@@ -775,7 +813,7 @@ public void setFields(final Field[] fields) {
}
/**
- * Set File name of class, aka SourceFile attribute value
+ * Sets File name of class, aka SourceFile attribute value
*/
public void setFileName(final String fileName) {
this.fileName = fileName;
@@ -824,7 +862,7 @@ public void setRepository(final org.apache.bcel.util.Repository repository) { //
}
/**
- * Set absolute path to file this class was read from.
+ * Sets absolute path to file this class was read from.
*/
public void setSourceFileName(final String sourceFileName) {
this.sourceFileName = sourceFileName;
diff --git a/src/main/java/org/apache/bcel/classfile/LineNumber.java b/src/main/java/org/apache/bcel/classfile/LineNumber.java
index 8e654d2c61..4d8ab3fb25 100644
--- a/src/main/java/org/apache/bcel/classfile/LineNumber.java
+++ b/src/main/java/org/apache/bcel/classfile/LineNumber.java
@@ -42,11 +42,11 @@ public final class LineNumber implements Cloneable, Node {
/** Program Counter (PC) corresponds to line */
private @NonNegative int startPc;
- /** number in source file */
+ /** Number in source file */
private @NonNegative int lineNumber;
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param file Input stream
* @throws IOException if an I/O Exception occurs in readUnsignedShort
diff --git a/src/main/java/org/apache/bcel/classfile/LineNumberTable.java b/src/main/java/org/apache/bcel/classfile/LineNumberTable.java
index ad13ae3c2c..44448598b6 100644
--- a/src/main/java/org/apache/bcel/classfile/LineNumberTable.java
+++ b/src/main/java/org/apache/bcel/classfile/LineNumberTable.java
@@ -46,7 +46,7 @@ public final class LineNumberTable extends Attribute implements Iterable bcelComparator = new BCELComparator() {
@Override
- public boolean equals(final Object o1, final Object o2) {
- final Method THIS = (Method) o1;
- final Method THAT = (Method) o2;
- return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature());
+ public boolean equals(final Method a, final Method b) {
+ return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
- public int hashCode(final Object o) {
- final Method THIS = (Method) o;
- return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
+ public int hashCode(final Method o) {
+ return o != null ? Objects.hash(o.getSignature(), o.getName()) : 0;
}
};
@@ -64,21 +61,21 @@ public int hashCode(final Object o) {
static final Method[] EMPTY_METHOD_ARRAY = {};
/**
- * @return Comparison strategy object
+ * @return Comparison strategy object.
*/
@Pure
- public static BCELComparator getComparator() {
+ public static BCELComparator getComparator() {
return bcelComparator;
}
/**
- * @param comparator Comparison strategy object
+ * @param comparator Comparison strategy object.
*/
- public static void setComparator(final BCELComparator comparator) {
+ public static void setComparator(final BCELComparator comparator) {
bcelComparator = comparator;
}
- // annotations defined on the parameters of a method
+ /** Annotations defined on the parameters of a method. */
private ParameterAnnotationEntry[] parameterAnnotationEntries;
/**
@@ -88,7 +85,7 @@ public Method() {
}
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param file Input stream
* @throws IOException if an I/O error occurs.
@@ -145,7 +142,7 @@ public Method copy(final ConstantPool constantPool) {
*/
@Override
public boolean equals(final @Nullable Object obj) {
- return bcelComparator.equals(this, obj);
+ return obj instanceof Method && bcelComparator.equals(this, (Method) obj);
}
/**
diff --git a/src/main/java/org/apache/bcel/classfile/MethodParameter.java b/src/main/java/org/apache/bcel/classfile/MethodParameter.java
index d59fce2141..a36c1c6ce1 100644
--- a/src/main/java/org/apache/bcel/classfile/MethodParameter.java
+++ b/src/main/java/org/apache/bcel/classfile/MethodParameter.java
@@ -30,6 +30,9 @@
/**
* Entry of the parameters table.
+ *
+ * Implements {@link Node} as of 6.7.0.
+ *
*
* @see The class File Format :
* The MethodParameters Attribute
@@ -48,7 +51,7 @@ public MethodParameter() {
}
/**
- * Construct object from input stream.
+ * Constructs an instance from a DataInput.
*
* @param input Input stream
* @throws IOException if an I/O error occurs.
@@ -78,7 +81,7 @@ public MethodParameter copy() {
}
/**
- * Dump object to file stream on binary format.
+ * Dumps object to file stream on binary format.
*
* @param file Output file stream
* @throws IOException if an I/O error occurs.
@@ -100,7 +103,10 @@ public int getAccessFlags() {
}
/**
- * Returns the name of the parameter.
+ * Gets the name of the parameter.
+ *
+ * @param constantPool The pool to query.
+ * @return Constant from the given pool.
*/
public @Nullable String getParameterName(final ConstantPool constantPool) {
if (nameIndex == 0) {
diff --git a/src/main/java/org/apache/bcel/classfile/Module.java b/src/main/java/org/apache/bcel/classfile/Module.java
index 65845f83d2..0a6656bf6a 100644
--- a/src/main/java/org/apache/bcel/classfile/Module.java
+++ b/src/main/java/org/apache/bcel/classfile/Module.java
@@ -57,7 +57,7 @@ public final class Module extends Attribute {
private ModuleProvides[] providesTable;
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index in constant pool
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/ModuleExports.java b/src/main/java/org/apache/bcel/classfile/ModuleExports.java
index e7b922c60f..216668ee32 100644
--- a/src/main/java/org/apache/bcel/classfile/ModuleExports.java
+++ b/src/main/java/org/apache/bcel/classfile/ModuleExports.java
@@ -40,7 +40,7 @@ public final class ModuleExports implements Cloneable, Node {
private final int[] exportsToIndex; // points to CONSTANT_Module_info
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param file Input stream
* @throws IOException if an I/O Exception occurs in readUnsignedShort
diff --git a/src/main/java/org/apache/bcel/classfile/ModuleMainClass.java b/src/main/java/org/apache/bcel/classfile/ModuleMainClass.java
index c4a55d7126..b6f98232ee 100644
--- a/src/main/java/org/apache/bcel/classfile/ModuleMainClass.java
+++ b/src/main/java/org/apache/bcel/classfile/ModuleMainClass.java
@@ -40,7 +40,7 @@ public final class ModuleMainClass extends Attribute {
private @NonNegative int mainClassIndex;
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index in constant pool
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/ModuleOpens.java b/src/main/java/org/apache/bcel/classfile/ModuleOpens.java
index f18f18b319..dc27b68609 100644
--- a/src/main/java/org/apache/bcel/classfile/ModuleOpens.java
+++ b/src/main/java/org/apache/bcel/classfile/ModuleOpens.java
@@ -40,7 +40,7 @@ public final class ModuleOpens implements Cloneable, Node {
private final int[] opensToIndex; // points to CONSTANT_Module_info
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param file Input stream
* @throws IOException if an I/O Exception occurs in readUnsignedShort
diff --git a/src/main/java/org/apache/bcel/classfile/ModulePackages.java b/src/main/java/org/apache/bcel/classfile/ModulePackages.java
index 2fe96de1a7..7d284346aa 100644
--- a/src/main/java/org/apache/bcel/classfile/ModulePackages.java
+++ b/src/main/java/org/apache/bcel/classfile/ModulePackages.java
@@ -42,7 +42,7 @@ public final class ModulePackages extends Attribute {
private int[] packageIndexTable;
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index in constant pool
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/ModuleProvides.java b/src/main/java/org/apache/bcel/classfile/ModuleProvides.java
index 7a4af53934..49d869419d 100644
--- a/src/main/java/org/apache/bcel/classfile/ModuleProvides.java
+++ b/src/main/java/org/apache/bcel/classfile/ModuleProvides.java
@@ -39,7 +39,7 @@ public final class ModuleProvides implements Cloneable, Node {
private final int[] providesWithIndex; // points to CONSTANT_Class_info
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param file Input stream
* @throws IOException if an I/O Exception occurs in readUnsignedShort
diff --git a/src/main/java/org/apache/bcel/classfile/ModuleRequires.java b/src/main/java/org/apache/bcel/classfile/ModuleRequires.java
index 2bbc605b90..ff7ac4bf02 100644
--- a/src/main/java/org/apache/bcel/classfile/ModuleRequires.java
+++ b/src/main/java/org/apache/bcel/classfile/ModuleRequires.java
@@ -39,7 +39,7 @@ public final class ModuleRequires implements Cloneable, Node {
private final @NonNegative int requiresVersionIndex; // either 0 or points to CONSTANT_Utf8_info
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param file Input stream
* @throws IOException if an I/O Exception occurs in readUnsignedShort
diff --git a/src/main/java/org/apache/bcel/classfile/NestMembers.java b/src/main/java/org/apache/bcel/classfile/NestMembers.java
index 4f6536c0b3..0c2f9aed20 100644
--- a/src/main/java/org/apache/bcel/classfile/NestMembers.java
+++ b/src/main/java/org/apache/bcel/classfile/NestMembers.java
@@ -43,7 +43,7 @@ public final class NestMembers extends Attribute {
private int[] classes;
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index in constant pool
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/Node.java b/src/main/java/org/apache/bcel/classfile/Node.java
index 1fecc0cf9e..51a9bfbec3 100644
--- a/src/main/java/org/apache/bcel/classfile/Node.java
+++ b/src/main/java/org/apache/bcel/classfile/Node.java
@@ -21,5 +21,5 @@
*/
public interface Node {
- void accept(Visitor obj);
+ void accept(Visitor visitor);
}
diff --git a/src/main/java/org/apache/bcel/classfile/PMGClass.java b/src/main/java/org/apache/bcel/classfile/PMGClass.java
index 763c902e5a..dd6f7b7468 100644
--- a/src/main/java/org/apache/bcel/classfile/PMGClass.java
+++ b/src/main/java/org/apache/bcel/classfile/PMGClass.java
@@ -38,7 +38,7 @@ public final class PMGClass extends Attribute {
private @NonNegative int pmgIndex;
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index in constant pool to CONSTANT_Utf8
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java b/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
index e3e425c197..d3ffa6e8a3 100644
--- a/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
+++ b/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
@@ -49,7 +49,7 @@ public static ParameterAnnotationEntry[] createParameterAnnotationEntries(final
private final AnnotationEntry[] annotationTable;
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param input Input stream
* @throws IOException if an I/O error occurs.
diff --git a/src/main/java/org/apache/bcel/classfile/Signature.java b/src/main/java/org/apache/bcel/classfile/Signature.java
index dd419e2d67..3605ce182b 100644
--- a/src/main/java/org/apache/bcel/classfile/Signature.java
+++ b/src/main/java/org/apache/bcel/classfile/Signature.java
@@ -161,7 +161,7 @@ public static String translate(final String s) {
private @NonNegative int signatureIndex;
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param nameIndex Index in constant pool to CONSTANT_Utf8
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java b/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java
index 804c38844c..9958a10b18 100644
--- a/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java
+++ b/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java
@@ -54,7 +54,7 @@ public void dump(final DataOutputStream dos) throws IOException {
dos.writeShort(getIndex());
break;
default:
- throw new ClassFormatException("SimpleElementValue doesnt know how to write out type " + type);
+ throw new ClassFormatException("SimpleElementValue doesn't know how to write out type " + type);
}
}
@@ -69,7 +69,7 @@ public void dump(final DataOutputStream dos) throws IOException {
@Pure
public boolean getValueBoolean() {
if (super.getType() != PRIMITIVE_BOOLEAN) {
- throw new IllegalStateException("Dont call getValueBoolean() on a non BOOLEAN ElementValue");
+ throw new IllegalStateException("Don't call getValueBoolean() on a non BOOLEAN ElementValue");
}
final ConstantInteger bo = (ConstantInteger) super.getConstantPool().getConstant(getIndex());
return bo.getBytes() != 0;
@@ -78,7 +78,7 @@ public boolean getValueBoolean() {
@Pure
public byte getValueByte() {
if (super.getType() != PRIMITIVE_BYTE) {
- throw new IllegalStateException("Dont call getValueByte() on a non BYTE ElementValue");
+ throw new IllegalStateException("Don't call getValueByte() on a non BYTE ElementValue");
}
return (byte) super.getConstantPool().getConstantInteger(getIndex()).getBytes();
}
@@ -87,7 +87,7 @@ public byte getValueByte() {
@Pure
public char getValueChar() {
if (super.getType() != PRIMITIVE_CHAR) {
- throw new IllegalStateException("Dont call getValueChar() on a non CHAR ElementValue");
+ throw new IllegalStateException("Don't call getValueChar() on a non CHAR ElementValue");
}
return (char) super.getConstantPool().getConstantInteger(getIndex()).getBytes();
}
@@ -95,7 +95,7 @@ public char getValueChar() {
@Pure
public double getValueDouble() {
if (super.getType() != PRIMITIVE_DOUBLE) {
- throw new IllegalStateException("Dont call getValueDouble() on a non DOUBLE ElementValue");
+ throw new IllegalStateException("Don't call getValueDouble() on a non DOUBLE ElementValue");
}
final ConstantDouble d = (ConstantDouble) super.getConstantPool().getConstant(getIndex());
return d.getBytes();
@@ -104,7 +104,7 @@ public double getValueDouble() {
@Pure
public float getValueFloat() {
if (super.getType() != PRIMITIVE_FLOAT) {
- throw new IllegalStateException("Dont call getValueFloat() on a non FLOAT ElementValue");
+ throw new IllegalStateException("Don't call getValueFloat() on a non FLOAT ElementValue");
}
final ConstantFloat f = (ConstantFloat) super.getConstantPool().getConstant(getIndex());
return f.getBytes();
@@ -113,7 +113,7 @@ public float getValueFloat() {
@Pure
public int getValueInt() {
if (super.getType() != PRIMITIVE_INT) {
- throw new IllegalStateException("Dont call getValueInt() on a non INT ElementValue");
+ throw new IllegalStateException("Don't call getValueInt() on a non INT ElementValue");
}
return super.getConstantPool().getConstantInteger(getIndex()).getBytes();
}
@@ -121,7 +121,7 @@ public int getValueInt() {
@Pure
public long getValueLong() {
if (super.getType() != PRIMITIVE_LONG) {
- throw new IllegalStateException("Dont call getValueLong() on a non LONG ElementValue");
+ throw new IllegalStateException("Don't call getValueLong() on a non LONG ElementValue");
}
final ConstantLong j = (ConstantLong) super.getConstantPool().getConstant(getIndex());
return j.getBytes();
@@ -130,7 +130,7 @@ public long getValueLong() {
@Pure
public short getValueShort() {
if (super.getType() != PRIMITIVE_SHORT) {
- throw new IllegalStateException("Dont call getValueShort() on a non SHORT ElementValue");
+ throw new IllegalStateException("Don't call getValueShort() on a non SHORT ElementValue");
}
final ConstantInteger s = (ConstantInteger) super.getConstantPool().getConstant(getIndex());
return (short) s.getBytes();
@@ -138,7 +138,7 @@ public short getValueShort() {
public String getValueString() {
if (super.getType() != STRING) {
- throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue");
+ throw new IllegalStateException("Don't call getValueString() on a non STRING ElementValue");
}
return super.getConstantPool().getConstantUtf8(getIndex()).getBytes();
}
diff --git a/src/main/java/org/apache/bcel/classfile/SourceFile.java b/src/main/java/org/apache/bcel/classfile/SourceFile.java
index f34a7b73c1..e2656fb99c 100644
--- a/src/main/java/org/apache/bcel/classfile/SourceFile.java
+++ b/src/main/java/org/apache/bcel/classfile/SourceFile.java
@@ -40,7 +40,7 @@ public final class SourceFile extends Attribute {
private @NonNegative int sourceFileIndex;
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index in constant pool to CONSTANT_Utf8
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/StackMap.java b/src/main/java/org/apache/bcel/classfile/StackMap.java
index 8add9339a1..31bc38f5c2 100644
--- a/src/main/java/org/apache/bcel/classfile/StackMap.java
+++ b/src/main/java/org/apache/bcel/classfile/StackMap.java
@@ -53,7 +53,7 @@ public final class StackMap extends Attribute {
private StackMapEntry[] table; // Table of stack map entries
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index of name
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/StackMapEntry.java b/src/main/java/org/apache/bcel/classfile/StackMapEntry.java
index 0664a6baa7..1bca6823dd 100644
--- a/src/main/java/org/apache/bcel/classfile/StackMapEntry.java
+++ b/src/main/java/org/apache/bcel/classfile/StackMapEntry.java
@@ -60,7 +60,7 @@ public final class StackMapEntry implements Node, Cloneable {
private ConstantPool constantPool;
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param dataInput Input stream
* @throws IOException if an I/O error occurs.
@@ -76,9 +76,7 @@ public final class StackMapEntry implements Node, Cloneable {
} else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
byteCodeOffset = dataInput.readUnsignedShort();
typesOfStackItems = new StackMapType[] { new StackMapType(dataInput, constantPool) };
- } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) {
- byteCodeOffset = dataInput.readUnsignedShort();
- } else if (frameType == Const.SAME_FRAME_EXTENDED) {
+ } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX || frameType == Const.SAME_FRAME_EXTENDED) {
byteCodeOffset = dataInput.readUnsignedShort();
} else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) {
byteCodeOffset = dataInput.readUnsignedShort();
@@ -168,7 +166,7 @@ public StackMapEntry copy() {
try {
e = (StackMapEntry) clone();
} catch (final CloneNotSupportedException ex) {
- throw new Error("Clone Not Supported");
+ throw new UnsupportedOperationException("Clone Not Supported", ex);
}
e.typesOfLocals = new StackMapType[typesOfLocals.length];
@@ -191,9 +189,7 @@ public void dump(final DataOutputStream file) throws IOException {
} else if (frameType == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
file.writeShort(byteCodeOffset);
typesOfStackItems[0].dump(file);
- } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX) {
- file.writeShort(byteCodeOffset);
- } else if (frameType == Const.SAME_FRAME_EXTENDED) {
+ } else if (frameType >= Const.CHOP_FRAME && frameType <= Const.CHOP_FRAME_MAX || frameType == Const.SAME_FRAME_EXTENDED) {
file.writeShort(byteCodeOffset);
} else if (frameType >= Const.APPEND_FRAME && frameType <= Const.APPEND_FRAME_MAX) {
file.writeShort(byteCodeOffset);
diff --git a/src/main/java/org/apache/bcel/classfile/StackMapType.java b/src/main/java/org/apache/bcel/classfile/StackMapType.java
index 963ecff1e9..dd9595ce0c 100644
--- a/src/main/java/org/apache/bcel/classfile/StackMapType.java
+++ b/src/main/java/org/apache/bcel/classfile/StackMapType.java
@@ -34,9 +34,9 @@
* @see Const
*/
@AnnotatedFor({"signedness"})
-public final class StackMapType implements Cloneable {
+public final class StackMapType implements Node, Cloneable {
- public static final StackMapType[] EMPTY_ARRAY = {}; // must be public because BCELifier code generator writes calls to it
+ public static final StackMapType[] EMPTY_ARRAY = {}; // BCELifier code generator writes calls to constructor translating null to EMPTY_ARRAY
private byte type;
private @NonNegative int index; // Index to CONSTANT_Class or offset
@@ -53,7 +53,7 @@ public StackMapType(final byte type, final @NonNegative int index, final Constan
}
/**
- * Construct object from file stream.
+ * Constructs object from file stream.
*
* @param file Input stream
* @throws IOException if an I/O error occurs.
@@ -66,6 +66,18 @@ public StackMapType(final byte type, final @NonNegative int index, final Constan
this.constantPool = constantPool;
}
+ /**
+ * 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.
+ *
+ * @param v Visitor object
+ * @since 6.8.0
+ */
+ @Override
+ public void accept(final Visitor v) {
+ v.visitStackMapType(this);
+ }
+
private byte checkType(final byte type) {
if (type < Const.ITEM_Bogus || type > Const.ITEM_NewObject) {
throw new ClassFormatException("Illegal type for StackMapType: " + type);
@@ -99,6 +111,15 @@ public void dump(final DataOutputStream file) throws IOException {
}
}
+ /**
+ * Gets the class name of this StackMapType from the constant pool at index position.
+ * @return the fully qualified name of the class for this StackMapType.
+ * @since 6.8.0
+ */
+ public String getClassName() {
+ return constantPool.constantToString(index, Const.CONSTANT_Class);
+ }
+
/**
* @return Constant pool used by this object.
*/
@@ -133,7 +154,7 @@ private String printIndex() {
if (index < 0) {
return ", class=";
}
- return ", class=" + constantPool.constantToString(index, Const.CONSTANT_Class);
+ return ", class=" + getClassName();
}
if (type == Const.ITEM_NewObject) {
return ", offset=" + index;
diff --git a/src/main/java/org/apache/bcel/classfile/Synthetic.java b/src/main/java/org/apache/bcel/classfile/Synthetic.java
index 16f61a091d..1c83b68bed 100644
--- a/src/main/java/org/apache/bcel/classfile/Synthetic.java
+++ b/src/main/java/org/apache/bcel/classfile/Synthetic.java
@@ -52,7 +52,7 @@ public Synthetic(final @NonNegative int nameIndex, final @NonNegative int length
}
/**
- * Construct object from input stream.
+ * Constructs object from input stream.
*
* @param nameIndex Index in constant pool to CONSTANT_Utf8
* @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/Utility.java b/src/main/java/org/apache/bcel/classfile/Utility.java
index 618d2cfe39..c92b3341a5 100644
--- a/src/main/java/org/apache/bcel/classfile/Utility.java
+++ b/src/main/java/org/apache/bcel/classfile/Utility.java
@@ -57,7 +57,7 @@ public abstract class Utility {
/**
* Decode characters into bytes. Used by decode()
*/
- private static class JavaReader extends FilterReader {
+ private static final class JavaReader extends FilterReader {
public JavaReader(final Reader in) {
super(in);
@@ -96,10 +96,10 @@ public int read(final char[] cbuf, final int off, final int len) throws IOExcept
}
/**
- * Encode bytes into valid java identifier characters. Used by
+ * Encode bytes into valid Java identifier characters. Used by
* encode()
*/
- private static class JavaWriter extends FilterWriter {
+ private static final class JavaWriter extends FilterWriter {
public JavaWriter(final Writer out) {
super(out);
@@ -439,7 +439,9 @@ public static String codeToString(final ByteSequence bytes, final ConstantPool c
case Const.NEW:
case Const.CHECKCAST:
buf.append("\t");
- //$FALL-THROUGH$
+ index = bytes.readUnsignedShort();
+ buf.append("\t<").append(constantPool.constantToString(index, Const.CONSTANT_Class)).append(">").append(verbose ? " (" + index + ")" : "");
+ break;
case Const.INSTANCEOF:
index = bytes.readUnsignedShort();
buf.append("\t<").append(constantPool.constantToString(index, Const.CONSTANT_Class)).append(">").append(verbose ? " (" + index + ")" : "");
@@ -868,7 +870,7 @@ public static String[] methodSignatureArgumentTypes(final String signature, fina
// Skip any type arguments to read argument declarations between '(' and ')'
index = signature.indexOf('(') + 1;
if (index <= 0) {
- throw new ClassFormatException("Invalid method signature: " + signature);
+ throw new InvalidMethodSignatureException(signature);
}
while (signature.charAt(index) != ')') {
vec.add(typeSignatureToString(signature.substring(index), chopit));
@@ -876,7 +878,7 @@ public static String[] methodSignatureArgumentTypes(final String signature, fina
index += unwrap(CONSUMER_CHARS); // update position
}
} catch (final StringIndexOutOfBoundsException e) { // Should never occur
- throw new ClassFormatException("Invalid method signature: " + signature, e);
+ throw new InvalidMethodSignatureException(signature, e);
}
return vec.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
@@ -907,11 +909,11 @@ public static String methodSignatureReturnType(final String signature, final boo
// Read return type after ')'
index = signature.lastIndexOf(')') + 1;
if (index <= 0) {
- throw new ClassFormatException("Invalid method signature: " + signature);
+ throw new InvalidMethodSignatureException(signature);
}
type = typeSignatureToString(signature.substring(index), chopit);
} catch (final StringIndexOutOfBoundsException e) { // Should never occur
- throw new ClassFormatException("Invalid method signature: " + signature, e);
+ throw new InvalidMethodSignatureException(signature, e);
}
return type;
}
@@ -963,7 +965,7 @@ public static String methodSignatureToString(final String signature, final Strin
// Skip any type arguments to read argument declarations between '(' and ')'
index = signature.indexOf('(') + 1;
if (index <= 0) {
- throw new ClassFormatException("Invalid method signature: " + signature);
+ throw new InvalidMethodSignatureException(signature);
}
while (signature.charAt(index) != ')') {
final String paramType = typeSignatureToString(signature.substring(index), chopit);
@@ -989,7 +991,7 @@ public static String methodSignatureToString(final String signature, final Strin
// Read return type after ')'
type = typeSignatureToString(signature.substring(index), chopit);
} catch (final StringIndexOutOfBoundsException e) { // Should never occur
- throw new ClassFormatException("Invalid method signature: " + signature, e);
+ throw new InvalidMethodSignatureException(signature, e);
}
// ignore any throws information in the signature
if (buf.length() > 1) {
@@ -1252,12 +1254,12 @@ public static byte typeOfMethodSignature(final String signature) throws ClassFor
int index;
try {
if (signature.charAt(0) != '(') {
- throw new ClassFormatException("Invalid method signature: " + signature);
+ throw new InvalidMethodSignatureException(signature);
}
index = signature.lastIndexOf(')') + 1;
return typeOfSignature(signature.substring(index));
} catch (final StringIndexOutOfBoundsException e) {
- throw new ClassFormatException("Invalid method signature: " + signature, e);
+ throw new InvalidMethodSignatureException(signature, e);
}
}
@@ -1301,10 +1303,10 @@ public static byte typeOfSignature(final String signature) throws ClassFormatExc
case '*':
return typeOfSignature(signature.substring(1));
default:
- throw new ClassFormatException("Invalid method signature: " + signature);
+ throw new InvalidMethodSignatureException(signature);
}
} catch (final StringIndexOutOfBoundsException e) {
- throw new ClassFormatException("Invalid method signature: " + signature, e);
+ throw new InvalidMethodSignatureException(signature, e);
}
}
diff --git a/src/main/java/org/apache/bcel/classfile/Visitor.java b/src/main/java/org/apache/bcel/classfile/Visitor.java
index b4670705cc..4f4b5c2116 100644
--- a/src/main/java/org/apache/bcel/classfile/Visitor.java
+++ b/src/main/java/org/apache/bcel/classfile/Visitor.java
@@ -225,6 +225,15 @@ default void visitNestMembers(final NestMembers obj) {
void visitStackMapEntry(StackMapEntry obj);
+ /**
+ * Visits a {@link StackMapType} object.
+ * @param obj object to visit
+ * @since 6.8.0
+ */
+ default void visitStackMapType(final StackMapType obj) {
+ // empty
+ }
+
void visitSynthetic(Synthetic obj);
void visitUnknown(Unknown obj);
diff --git a/src/main/java/org/apache/bcel/classfile/package-info.java b/src/main/java/org/apache/bcel/classfile/package-info.java
new file mode 100644
index 0000000000..f7bd9852e9
--- /dev/null
+++ b/src/main/java/org/apache/bcel/classfile/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Classes that describe the structure of a Java class file and a class file parser.
+ */
+package org.apache.bcel.classfile;
diff --git a/src/main/java/org/apache/bcel/generic/ARRAYLENGTH.java b/src/main/java/org/apache/bcel/generic/ARRAYLENGTH.java
index b7fca1b05b..4b277ec87a 100644
--- a/src/main/java/org/apache/bcel/generic/ARRAYLENGTH.java
+++ b/src/main/java/org/apache/bcel/generic/ARRAYLENGTH.java
@@ -28,7 +28,7 @@
public class ARRAYLENGTH extends Instruction implements ExceptionThrower, StackProducer, StackConsumer /* since 6.0 */ {
/**
- * Get length of array
+ * Gets length of array
*/
public ARRAYLENGTH() {
super(org.apache.bcel.Const.ARRAYLENGTH, (short) 1);
diff --git a/src/main/java/org/apache/bcel/generic/ATHROW.java b/src/main/java/org/apache/bcel/generic/ATHROW.java
index 3d774f4145..10c3096bb2 100644
--- a/src/main/java/org/apache/bcel/generic/ATHROW.java
+++ b/src/main/java/org/apache/bcel/generic/ATHROW.java
@@ -25,7 +25,7 @@
* Stack: ..., objectref -> objectref
*
*/
-public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower {
+public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower, StackConsumer {
/**
* Throw exception
@@ -44,6 +44,7 @@ public ATHROW() {
public void accept(final Visitor v) {
v.visitUnconditionalBranch(this);
v.visitExceptionThrower(this);
+ v.visitStackConsumer(this);
v.visitATHROW(this);
}
diff --git a/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java b/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java
index 57fa3c1461..7051ca56ae 100644
--- a/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java
+++ b/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java
@@ -300,7 +300,9 @@ public final String getTypeSignature() {
}
/**
- * Returns list of ElementNameValuePair objects
+ * Returns list of ElementNameValuePair objects.
+ *
+ * @return list of ElementNameValuePair objects.
*/
@Pure
public List getValues() {
diff --git a/src/main/java/org/apache/bcel/generic/ArrayType.java b/src/main/java/org/apache/bcel/generic/ArrayType.java
index d11e1f87df..ead4890ff5 100644
--- a/src/main/java/org/apache/bcel/generic/ArrayType.java
+++ b/src/main/java/org/apache/bcel/generic/ArrayType.java
@@ -45,7 +45,7 @@ public ArrayType(final byte type, final @NonNegative int dimensions) {
/**
* Convenience constructor for reference array type, e.g. Object[]
*
- * @param className complete name of class (java.lang.String, e.g.)
+ * @param className complete name of class ({@link String}, for example)
* @param dimensions array dimensions
*/
public ArrayType(final @ClassGetName String className, final @NonNegative int dimensions) {
@@ -83,7 +83,7 @@ public ArrayType(final Type type, final @NonNegative int dimensions) {
buf.append('[');
}
buf.append(basicType.getSignature());
- super.setSignature(buf.toString());
+ this.signature = buf.toString();
}
/**
diff --git a/src/main/java/org/apache/bcel/generic/BranchHandle.java b/src/main/java/org/apache/bcel/generic/BranchHandle.java
index 993c606048..8b60428fe2 100644
--- a/src/main/java/org/apache/bcel/generic/BranchHandle.java
+++ b/src/main/java/org/apache/bcel/generic/BranchHandle.java
@@ -61,7 +61,7 @@ public InstructionHandle getTarget() {
}
/**
- * Set new contents. Old instruction is disposed and may not be used anymore.
+ * Sets new contents. Old instruction is disposed and may not be used anymore.
*/
@Override // This is only done in order to apply the additional type check; could be merged with super impl.
public void setInstruction(final Instruction i) { // TODO could be package-protected?
diff --git a/src/main/java/org/apache/bcel/generic/BranchInstruction.java b/src/main/java/org/apache/bcel/generic/BranchInstruction.java
index e9c624cdad..4a55bad2fc 100644
--- a/src/main/java/org/apache/bcel/generic/BranchInstruction.java
+++ b/src/main/java/org/apache/bcel/generic/BranchInstruction.java
@@ -199,7 +199,7 @@ protected void setPosition(final @NonNegative int position) {
}
/**
- * Set branch target
+ * Sets branch target
*
* @param target branch target
*/
diff --git a/src/main/java/org/apache/bcel/generic/CPInstruction.java b/src/main/java/org/apache/bcel/generic/CPInstruction.java
index bc0941047a..ba1fcf56c0 100644
--- a/src/main/java/org/apache/bcel/generic/CPInstruction.java
+++ b/src/main/java/org/apache/bcel/generic/CPInstruction.java
@@ -109,7 +109,7 @@ protected void initFromFile(final ByteSequence bytes, final boolean wide) throws
}
/**
- * Set the index to constant pool.
+ * Sets the index to constant pool.
*
* @param index in constant pool.
*/
diff --git a/src/main/java/org/apache/bcel/generic/ClassGen.java b/src/main/java/org/apache/bcel/generic/ClassGen.java
index 354e82069d..7709132bd1 100644
--- a/src/main/java/org/apache/bcel/generic/ClassGen.java
+++ b/src/main/java/org/apache/bcel/generic/ClassGen.java
@@ -44,26 +44,23 @@
import org.checkerframework.dataflow.qual.Pure;
/**
- * Template class for building up a java class. May be initialized with an existing java class (file).
+ * Template class for building up a java class. May be initialized with an existing Java class (file).
*
* @see JavaClass
*/
@AnnotatedFor({"nullness","signature","signedness"})
public class ClassGen extends AccessFlags implements Cloneable {
- private static BCELComparator bcelComparator = new BCELComparator() {
+ private static BCELComparator bcelComparator = new BCELComparator() {
@Override
- public boolean equals(final Object o1, final Object o2) {
- final ClassGen THIS = (ClassGen) o1;
- final ClassGen THAT = (ClassGen) o2;
- return Objects.equals(THIS.getClassName(), THAT.getClassName());
+ public boolean equals(final ClassGen a, final ClassGen b) {
+ return a == b || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
}
@Override
- public int hashCode(final Object o) {
- final ClassGen THIS = (ClassGen) o;
- return THIS.getClassName().hashCode();
+ public int hashCode(final ClassGen o) {
+ return o != null ? Objects.hashCode(o.getClassName()) : 0;
}
};
@@ -71,14 +68,14 @@ public int hashCode(final Object o) {
* @return Comparison strategy object
*/
@Pure
- public static BCELComparator getComparator() {
+ public static BCELComparator getComparator() {
return bcelComparator;
}
/**
* @param comparator Comparison strategy object
*/
- public static void setComparator(final BCELComparator comparator) {
+ public static void setComparator(final BCELComparator comparator) {
bcelComparator = comparator;
}
@@ -247,7 +244,7 @@ public Object clone() {
try {
return super.clone();
} catch (final CloneNotSupportedException e) {
- throw new Error("Clone Not Supported"); // never happens
+ throw new UnsupportedOperationException("Clone Not Supported", e); // never happens
}
}
@@ -287,7 +284,7 @@ public boolean containsField(final Field f) {
*/
@Override
public boolean equals(final @Nullable Object obj) {
- return bcelComparator.equals(this, obj);
+ return obj instanceof ClassGen && bcelComparator.equals(this, (ClassGen) obj);
}
// J5TODO: Should we make calling unpackAnnotations() lazy and put it in here?
@@ -493,7 +490,7 @@ public void setConstantPool(final ConstantPoolGen constantPool) {
}
/**
- * Set major version number of class file, default value is 45 (JDK 1.1)
+ * Sets major version number of class file, default value is 45 (JDK 1.1)
*
* @param major major version number
*/
@@ -511,7 +508,7 @@ public void setMethods(final Method[] methods) {
}
/**
- * Set minor version number of class file, default value is 3 (JDK 1.1)
+ * Sets minor version number of class file, default value is 3 (JDK 1.1)
*
* @param minor minor version number
*/
diff --git a/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java b/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java
index 7e2e18b360..1f29996790 100644
--- a/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java
+++ b/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java
@@ -61,7 +61,7 @@ public Object clone() {
try {
return super.clone();
} catch (final CloneNotSupportedException e) {
- throw new Error("Clone Not Supported"); // never happens
+ throw new UnsupportedOperationException("Clone Not Supported", e); // never happens
}
}
@@ -80,7 +80,7 @@ public ObjectType getCatchType() {
}
/**
- * Get CodeException object.
+ * Gets CodeException object.
*
* This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods
* has been called for the instruction list.
@@ -122,7 +122,7 @@ public void setCatchType(final ObjectType catchType) {
}
/*
- * Set end of handler
+ * Sets end of handler
*
* @param endPc End of handled region (inclusive)
*/
@@ -132,7 +132,7 @@ public void setEndPC(final InstructionHandle endPc) { // TODO could be package-p
}
/*
- * Set handler code
+ * Sets handler code
*
* @param handlerPc Start of handler
*/
@@ -142,7 +142,7 @@ public void setHandlerPC(final InstructionHandle handlerPc) { // TODO could be p
}
/*
- * Set start of handler
+ * Sets start of handler
*
* @param startPc Start of handled region (inclusive)
*/
diff --git a/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java b/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java
index 325be3acb5..9e4e25b73c 100644
--- a/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java
+++ b/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java
@@ -114,9 +114,8 @@ public ConstantPoolGen(final Constant[] cs) {
final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE);
size = Math.min(Math.max(DEFAULT_BUFFER_SIZE, cs.length + 64), Const.MAX_CP_ENTRIES + 1);
- constants = new Constant[size];
+ constants = Arrays.copyOf(cs, size);
- System.arraycopy(cs, 0, constants, 0, cs.length);
if (cs.length > 0) {
index = cs.length;
}
@@ -549,12 +548,12 @@ protected void adjustSize() {
}
if (index + 3 >= size) {
- final Constant[] cs = constants;
+ final Constant[] tmp = constants;
size *= 2;
// the constant array shall not exceed the size of the constant pool
size = Math.min(size, Const.MAX_CP_ENTRIES + 1);
constants = new Constant[size];
- System.arraycopy(cs, 0, constants, 0, index);
+ System.arraycopy(tmp, 0, constants, 0, index);
}
}
diff --git a/src/main/java/org/apache/bcel/generic/ExceptionThrower.java b/src/main/java/org/apache/bcel/generic/ExceptionThrower.java
index 8fa73e76f9..b21c620135 100644
--- a/src/main/java/org/apache/bcel/generic/ExceptionThrower.java
+++ b/src/main/java/org/apache/bcel/generic/ExceptionThrower.java
@@ -18,7 +18,7 @@
/**
* Denote an instruction that may throw a run-time or a linking exception (or both) during execution. This is not quite
- * the truth as such; because all instructions may throw an java.lang.VirtualMachineError. These exceptions are omitted.
+ * the truth as such; because all instructions may throw a {@link VirtualMachineError}. These exceptions are omitted.
*
* The Lava Language Specification specifies exactly which RUN-TIME and which LINKING exceptions each
* instruction may throw which is reflected by the implementers. Due to the structure of the JVM specification, it may
diff --git a/src/main/java/org/apache/bcel/generic/FieldGen.java b/src/main/java/org/apache/bcel/generic/FieldGen.java
index 4b73c29ab3..bd8f20963b 100644
--- a/src/main/java/org/apache/bcel/generic/FieldGen.java
+++ b/src/main/java/org/apache/bcel/generic/FieldGen.java
@@ -46,34 +46,31 @@
@AnnotatedFor({"signedness"})
public class FieldGen extends FieldGenOrMethodGen {
- private static BCELComparator bcelComparator = new BCELComparator() {
+ private static BCELComparator bcelComparator = new BCELComparator() {
@Override
- public boolean equals(final Object o1, final Object o2) {
- final FieldGen THIS = (FieldGen) o1;
- final FieldGen THAT = (FieldGen) o2;
- return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature());
+ public boolean equals(final FieldGen a, final FieldGen b) {
+ return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
- public int hashCode(final Object o) {
- final FieldGen THIS = (FieldGen) o;
- return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
+ public int hashCode(final FieldGen o) {
+ return o != null ? Objects.hash(o.getSignature(), o.getName()) : 0;
}
};
/**
- * @return Comparison strategy object
+ * @return Comparison strategy object.
*/
@Pure
- public static BCELComparator getComparator() {
+ public static BCELComparator getComparator() {
return bcelComparator;
}
/**
- * @param comparator Comparison strategy object
+ * @param comparator Comparison strategy object.
*/
- public static void setComparator(final BCELComparator comparator) {
+ public static void setComparator(final BCELComparator comparator) {
bcelComparator = comparator;
}
@@ -84,8 +81,8 @@ public static void setComparator(final BCELComparator comparator) {
/**
* Instantiate from existing field.
*
- * @param field Field object
- * @param cp constant pool (must contain the same entries as the field's constant pool)
+ * @param field Field object.
+ * @param cp constant pool (must contain the same entries as the field's constant pool).
*/
public FieldGen(final Field field, final ConstantPoolGen cp) {
this(field.getAccessFlags(), Type.getType(field.getSignature()), field.getName(), cp);
@@ -190,11 +187,11 @@ public FieldGen copy(final ConstantPoolGen cp) {
*/
@Override
public boolean equals(final @Nullable Object obj) {
- return bcelComparator.equals(this, obj);
+ return obj instanceof FieldGen && bcelComparator.equals(this, (FieldGen) obj);
}
/**
- * Get field object after having set up all necessary values.
+ * Gets field object after having set up all necessary values.
*/
public Field getField() {
final String signature = getSignature();
@@ -210,10 +207,7 @@ public Field getField() {
}
public @Nullable String getInitValue() {
- if (value != null) {
- return value.toString();
- }
- return null;
+ return Objects.toString(value, null);
}
@Override
@@ -298,7 +292,7 @@ public void setInitValue(final short s) {
}
/**
- * Set (optional) initial value of field, otherwise it will be set to null/0/false by the JVM automatically.
+ * Sets (optional) initial value of field, otherwise it will be set to null/0/false by the JVM automatically.
*/
public void setInitValue(final String str) {
checkType(ObjectType.getInstance("java.lang.String"));
diff --git a/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java b/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java
index c42b5a8099..a6e2fe9eb3 100644
--- a/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java
@@ -91,7 +91,7 @@ public Object clone() {
try {
return super.clone();
} catch (final CloneNotSupportedException e) {
- throw new Error("Clone Not Supported"); // never happens
+ throw new UnsupportedOperationException("Clone Not Supported", e); // never happens
}
}
diff --git a/src/main/java/org/apache/bcel/generic/FieldOrMethod.java b/src/main/java/org/apache/bcel/generic/FieldOrMethod.java
index 24470e3f2e..5fcd6439d6 100644
--- a/src/main/java/org/apache/bcel/generic/FieldOrMethod.java
+++ b/src/main/java/org/apache/bcel/generic/FieldOrMethod.java
@@ -90,6 +90,9 @@ public ObjectType getLoadClassType(final ConstantPoolGen cpg) {
if (rt instanceof ObjectType) {
return (ObjectType) rt;
}
+ if (rt instanceof ArrayType) {
+ return Type.OBJECT;
+ }
throw new ClassGenException(rt.getClass().getCanonicalName() + " " + rt.getSignature() + " does not represent an ObjectType");
}
diff --git a/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java b/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java
index f028614ae2..906b3b597b 100644
--- a/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java
+++ b/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java
@@ -102,11 +102,11 @@ public Class>[] getExceptions() {
}
/**
- * Since InvokeDynamic doesn't refer to a reference type, just return java.lang.Object, as that is the only type we can
+ * Since InvokeDynamic doesn't refer to a reference type, just return {@link Object}, as that is the only type we can
* say for sure the reference will be.
*
* @param cpg the ConstantPoolGen used to create the instruction
- * @return an ObjectType for java.lang.Object
+ * @return an ObjectType for {@link Object}
* @since 6.1
*/
@Override
diff --git a/src/main/java/org/apache/bcel/generic/InstructionConst.java b/src/main/java/org/apache/bcel/generic/InstructionConst.java
index 3f3fb6b8e5..e45535a7e5 100644
--- a/src/main/java/org/apache/bcel/generic/InstructionConst.java
+++ b/src/main/java/org/apache/bcel/generic/InstructionConst.java
@@ -170,7 +170,7 @@ public final class InstructionConst {
public static final LocalVariableInstruction ISTORE_2 = new ISTORE(2);
/**
- * Get object via its opcode, for immutable instructions like branch instructions entries are set to null.
+ * Gets object via its opcode, for immutable instructions like branch instructions entries are set to null.
*/
static final Instruction[] INSTRUCTIONS = new Instruction[256];
diff --git a/src/main/java/org/apache/bcel/generic/InstructionConstants.java b/src/main/java/org/apache/bcel/generic/InstructionConstants.java
index 56d3dee6e2..afdaccd22f 100644
--- a/src/main/java/org/apache/bcel/generic/InstructionConstants.java
+++ b/src/main/java/org/apache/bcel/generic/InstructionConstants.java
@@ -37,7 +37,9 @@ public interface InstructionConstants {
/**
* Deprecated, consider private and ignore.
*/
- class Clinit {}
+ class Clinit {
+ // empty
+ }
/*
* NOTE these are not currently immutable, because Instruction has mutable protected fields opcode and length.
diff --git a/src/main/java/org/apache/bcel/generic/InstructionFactory.java b/src/main/java/org/apache/bcel/generic/InstructionFactory.java
index 4375b2de6c..bdc9ca556e 100644
--- a/src/main/java/org/apache/bcel/generic/InstructionFactory.java
+++ b/src/main/java/org/apache/bcel/generic/InstructionFactory.java
@@ -38,7 +38,7 @@
@AnnotatedFor({"signedness"})
public class InstructionFactory implements InstructionConstants {
- private static class MethodObject {
+ private static final class MethodObject {
final Type[] argTypes;
final Type resultType;
@@ -57,11 +57,13 @@ private static class MethodObject {
private static final String FQCN_STRING_BUFFER = "java.lang.StringBuffer";
- // N.N. These must agree with the order of Constants.T_CHAR through T_LONG
- private static final String[] shortNames = {"C", "F", "D", "B", "S", "I", "L"};
+ /**
+ * These must agree with the order of Constants.T_CHAR through T_LONG.
+ */
+ private static final String[] SHORT_NAMES = {"C", "F", "D", "B", "S", "I", "L"};
@SuppressWarnings("nullness") // indices 2 and 3 are never used
- private static final MethodObject[] appendMethodObjects = {
+ private static final MethodObject[] APPEND_METHOD_OBJECTS = {
new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.STRING }),
new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.OBJECT }), null, null, // indices 2, 3
new MethodObject(FQCN_STRING_BUFFER, APPEND, Type.STRINGBUFFER, new Type[] { Type.BOOLEAN }),
@@ -489,7 +491,7 @@ public InstructionFactory(final ConstantPoolGen cp) {
public Instruction createAppend(final Type type) {
final byte t = type.getType();
if (isString(type)) {
- return createInvoke(appendMethodObjects[0], Const.INVOKEVIRTUAL);
+ return createInvoke(APPEND_METHOD_OBJECTS[0], Const.INVOKEVIRTUAL);
}
switch (t) {
case Const.T_BOOLEAN:
@@ -500,10 +502,10 @@ public Instruction createAppend(final Type type) {
case Const.T_SHORT:
case Const.T_INT:
case Const.T_LONG:
- return createInvoke(appendMethodObjects[t], Const.INVOKEVIRTUAL);
+ return createInvoke(APPEND_METHOD_OBJECTS[t], Const.INVOKEVIRTUAL);
case Const.T_ARRAY:
case Const.T_OBJECT:
- return createInvoke(appendMethodObjects[1], Const.INVOKEVIRTUAL);
+ return createInvoke(APPEND_METHOD_OBJECTS[1], Const.INVOKEVIRTUAL);
default:
throw new IllegalArgumentException("No append for this type? " + type);
}
@@ -521,10 +523,10 @@ public Instruction createCast(final Type srcType, final Type destType) {
src = Const.T_INT;
}
@SuppressWarnings("signature") // string manipulation
- final @ClassGetName String name = "org.apache.bcel.generic." + shortNames[src - Const.T_CHAR] + "2" + shortNames[dest - Const.T_CHAR];
+ final @ClassGetName String name = "org.apache.bcel.generic." + SHORT_NAMES[src - Const.T_CHAR] + "2" + SHORT_NAMES[dest - Const.T_CHAR];
Instruction i = null;
try {
- i = (Instruction) Class.forName(name).newInstance();
+ i = (Instruction) Class.forName(name).getConstructor().newInstance();
} catch (final Exception e) {
throw new IllegalArgumentException("Could not find instruction: " + name, e);
}
diff --git a/src/main/java/org/apache/bcel/generic/InstructionHandle.java b/src/main/java/org/apache/bcel/generic/InstructionHandle.java
index 7ff9e04fb7..04634102ce 100644
--- a/src/main/java/org/apache/bcel/generic/InstructionHandle.java
+++ b/src/main/java/org/apache/bcel/generic/InstructionHandle.java
@@ -139,15 +139,12 @@ void dispose() {
}
/**
- * Get attribute of an instruction handle.
+ * Gets attribute of an instruction handle.
*
* @param key the key object to store/retrieve the attribute
*/
public @Nullable Object getAttribute(final Object key) {
- if (attributes != null) {
- return attributes.get(key);
- }
- return null;
+ return attributes != null ? attributes.get(key) : null;
}
/**
@@ -255,7 +252,7 @@ final InstructionHandle setNext(final InstructionHandle next) {
}
/**
- * Set the position, i.e., the byte code offset of the contained instruction.
+ * Sets the position, i.e., the byte code offset of the contained instruction.
*/
void setPosition(final @NonNegative int pos) {
i_position = pos;
diff --git a/src/main/java/org/apache/bcel/generic/InstructionList.java b/src/main/java/org/apache/bcel/generic/InstructionList.java
index 991055e13c..3358600fdc 100644
--- a/src/main/java/org/apache/bcel/generic/InstructionList.java
+++ b/src/main/java/org/apache/bcel/generic/InstructionList.java
@@ -517,7 +517,7 @@ public void dispose() {
}
/**
- * Get instruction handle for instruction at byte code position pos. This only works properly, if the list is freshly
+ * Gets instruction handle for instruction at byte code position pos. This only works properly, if the list is freshly
* initialized from a byte array or setPositions() has been called before this method.
*
* @param pos byte code position to search for
@@ -612,7 +612,7 @@ public InstructionHandle[] getInstructionHandles() {
}
/**
- * Get positions (offsets) of all instructions in the list. This relies on that the list has been freshly created from
+ * Gets positions (offsets) of all instructions in the list. This relies on that the list has been freshly created from
* an byte code array, or that setPositions() has been called. Otherwise this may be inaccurate.
*
* @return array containing all instruction's offset in byte code
@@ -1130,7 +1130,7 @@ public void setPositions(final boolean check) { // called by code in other packa
ih.setPosition(index);
pos[count++] = index;
/*
- * Get an estimate about how many additional bytes may be added, because BranchInstructions may have variable length
+ * Gets an estimate about how many additional bytes may be added, because BranchInstructions may have variable length
* depending on the target offset (short vs. int) or alignment issues (TABLESWITCH and LOOKUPSWITCH).
*/
switch (i.getOpcode()) {
@@ -1142,6 +1142,9 @@ public void setPositions(final boolean check) { // called by code in other packa
case Const.LOOKUPSWITCH:
maxAdditionalBytes += 3;
break;
+ default:
+ // TODO should this be an error?
+ break;
}
index += i.getLength();
}
@@ -1162,8 +1165,7 @@ public void setPositions(final boolean check) { // called by code in other packa
pos[count++] = index;
index += i.getLength();
}
- bytePositions = new int[count]; // Trim to proper size
- System.arraycopy(pos, 0, bytePositions, 0, count);
+ bytePositions = Arrays.copyOfRange(pos, 0, count); // Trim to proper size
}
/**
diff --git a/src/main/java/org/apache/bcel/generic/LCMP.java b/src/main/java/org/apache/bcel/generic/LCMP.java
index febcf441bf..c04c2cafc2 100644
--- a/src/main/java/org/apache/bcel/generic/LCMP.java
+++ b/src/main/java/org/apache/bcel/generic/LCMP.java
@@ -24,7 +24,6 @@
*
* Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -> ..., result <= -1, 0, 1>
*
- *
*/
public class LCMP extends Instruction implements TypedInstruction, StackProducer, StackConsumer {
diff --git a/src/main/java/org/apache/bcel/generic/LDC.java b/src/main/java/org/apache/bcel/generic/LDC.java
index 116535c96f..0ca1958f98 100644
--- a/src/main/java/org/apache/bcel/generic/LDC.java
+++ b/src/main/java/org/apache/bcel/generic/LDC.java
@@ -93,6 +93,8 @@ public Type getType(final ConstantPoolGen cpg) {
return Type.INT;
case org.apache.bcel.Const.CONSTANT_Class:
return Type.CLASS;
+ case org.apache.bcel.Const.CONSTANT_Dynamic:
+ return Type.OBJECT;
default: // Never reached
throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex());
}
@@ -112,7 +114,10 @@ public Object getValue(final ConstantPoolGen cpg) {
case org.apache.bcel.Const.CONSTANT_Class:
final int nameIndex = ((org.apache.bcel.classfile.ConstantClass) c).getNameIndex();
c = cpg.getConstantPool().getConstant(nameIndex);
- return Type.getType(((org.apache.bcel.classfile.ConstantUtf8) c).getBytes());
+ return Type.getType(Type.internalTypeNameToSignature(((org.apache.bcel.classfile.ConstantUtf8) c).getBytes()));
+ case org.apache.bcel.Const.CONSTANT_Dynamic:
+ // Really not sure what to return here, maybe a BootstrapMethod instance but how do we get it?
+ return c;
default: // Never reached
throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex());
}
@@ -128,7 +133,7 @@ protected void initFromFile(final ByteSequence bytes, final boolean wide) throws
}
/**
- * Set the index to constant pool and adjust size.
+ * Sets the index to constant pool and adjust size.
*/
@Override
public final void setIndex(final @NonNegative int index) {
diff --git a/src/main/java/org/apache/bcel/generic/LineNumberGen.java b/src/main/java/org/apache/bcel/generic/LineNumberGen.java
index 1b25b2c335..0cdb0b2f6c 100644
--- a/src/main/java/org/apache/bcel/generic/LineNumberGen.java
+++ b/src/main/java/org/apache/bcel/generic/LineNumberGen.java
@@ -55,7 +55,7 @@ public Object clone() {
try {
return super.clone();
} catch (final CloneNotSupportedException e) {
- throw new Error("Clone Not Supported"); // never happens
+ throw new UnsupportedOperationException("Clone Not Supported", e); // never happens
}
}
@@ -73,7 +73,7 @@ public InstructionHandle getInstruction() {
}
/**
- * Get LineNumber attribute .
+ * Gets LineNumber attribute.
*
* This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods
* has been called for the instruction list.
diff --git a/src/main/java/org/apache/bcel/generic/LocalVariableGen.java b/src/main/java/org/apache/bcel/generic/LocalVariableGen.java
index d76ef88e95..411fd46b68 100644
--- a/src/main/java/org/apache/bcel/generic/LocalVariableGen.java
+++ b/src/main/java/org/apache/bcel/generic/LocalVariableGen.java
@@ -87,7 +87,7 @@ public Object clone() {
try {
return super.clone();
} catch (final CloneNotSupportedException e) {
- throw new Error("Clone Not Supported"); // never happens
+ throw new UnsupportedOperationException("Clone Not Supported", e); // never happens
}
}
diff --git a/src/main/java/org/apache/bcel/generic/LocalVariableInstruction.java b/src/main/java/org/apache/bcel/generic/LocalVariableInstruction.java
index 1849074d33..5dba0a233b 100644
--- a/src/main/java/org/apache/bcel/generic/LocalVariableInstruction.java
+++ b/src/main/java/org/apache/bcel/generic/LocalVariableInstruction.java
@@ -167,7 +167,7 @@ protected void initFromFile(final ByteSequence bytes, final boolean wide) throws
}
/**
- * Set the local variable index. also updates opcode and length TODO Why?
+ * Sets the local variable index. also updates opcode and length TODO Why?
*
* @see #setIndexOnly(int)
*/
diff --git a/src/main/java/org/apache/bcel/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java
index 3eaf4f3c43..5a786a6f95 100644
--- a/src/main/java/org/apache/bcel/generic/MethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/MethodGen.java
@@ -108,19 +108,16 @@ static final class BranchTarget {
}
}
- private static BCELComparator bcelComparator = new BCELComparator() {
+ private static BCELComparator bcelComparator = new BCELComparator() {
@Override
- public boolean equals(final Object o1, final Object o2) {
- final FieldGenOrMethodGen THIS = (FieldGenOrMethodGen) o1;
- final FieldGenOrMethodGen THAT = (FieldGenOrMethodGen) o2;
- return Objects.equals(THIS.getName(), THAT.getName()) && Objects.equals(THIS.getSignature(), THAT.getSignature());
+ public boolean equals(final FieldGenOrMethodGen a, final FieldGenOrMethodGen b) {
+ return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
- public int hashCode(final Object o) {
- final FieldGenOrMethodGen THIS = (FieldGenOrMethodGen) o;
- return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
+ public int hashCode(final FieldGenOrMethodGen o) {
+ return o != null ? Objects.hash(o.getSignature(), o.getName()) : 0;
}
};
@@ -133,10 +130,10 @@ private static byte[] getByteCodes(final Method method) {
}
/**
- * @return Comparison strategy object
+ * @return Comparison strategy object.
*/
@Pure
- public static BCELComparator getComparator() {
+ public static BCELComparator getComparator() {
return bcelComparator;
}
@@ -213,9 +210,9 @@ public static BCELComparator getComparator() {
}
/**
- * @param comparator Comparison strategy object
+ * @param comparator Comparison strategy object.
*/
- public static void setComparator(final BCELComparator comparator) {
+ public static void setComparator(final BCELComparator comparator) {
bcelComparator = comparator;
}
@@ -643,7 +640,7 @@ private void ensureExistingParameterAnnotationsUnpacked() {
*/
@Override
public boolean equals(final @Nullable Object obj) {
- return bcelComparator.equals(this, obj);
+ return obj instanceof FieldGenOrMethodGen && bcelComparator.equals(this, (FieldGenOrMethodGen) obj);
}
// J5TODO: Should paramAnnotations be an array of arrays? Rather than an array of lists, this
@@ -804,7 +801,7 @@ public LocalVariableTypeTable getLocalVariableTypeTable() {
}
/**
- * Get method object. Never forget to call setMaxStack() or setMaxStack(max), respectively, before calling this method
+ * Gets method object. Never forget to call setMaxStack() or setMaxStack(max), respectively, before calling this method
* (the same applies for max locals).
*
* @return method object
@@ -1101,7 +1098,7 @@ public void setMaxLocals() { // TODO could be package-protected? (some tests wou
}
/**
- * Set maximum number of local variables.
+ * Sets maximum number of local variables.
*/
public void setMaxLocals(final @NonNegative int m) {
maxLocals = m;
@@ -1119,7 +1116,7 @@ public void setMaxStack() { // TODO could be package-protected? (some tests woul
}
/**
- * Set maximum stack size for this method.
+ * Sets maximum stack size for this method.
*/
public void setMaxStack(final @NonNegative int m) { // TODO could be package-protected?
maxStack = m;
diff --git a/src/main/java/org/apache/bcel/generic/ObjectType.java b/src/main/java/org/apache/bcel/generic/ObjectType.java
index 6c4110687e..b25dd24a7c 100644
--- a/src/main/java/org/apache/bcel/generic/ObjectType.java
+++ b/src/main/java/org/apache/bcel/generic/ObjectType.java
@@ -28,7 +28,7 @@
import org.checkerframework.framework.qual.AnnotatedFor;
/**
- * Denotes reference such as java.lang.String.
+ * Denotes reference such as {@link String}.
*/
@AnnotatedFor({"signature"})
public class ObjectType extends ReferenceType {
@@ -49,7 +49,7 @@ public static ObjectType getInstance(final @BinaryName String className) {
/**
* Constructs a new instance.
*
- * @param className fully qualified class name, e.g. java.lang.String
+ * @param className fully qualified class name, e.g. {@link String}
*/
// The argument can be either @BinaryName or @InternalForm. There is no Signature Checker
// annotation for that. Use @BinaryName since the documentation is closest to that.
diff --git a/src/main/java/org/apache/bcel/generic/RET.java b/src/main/java/org/apache/bcel/generic/RET.java
index 1ed13b37a5..d8374efeee 100644
--- a/src/main/java/org/apache/bcel/generic/RET.java
+++ b/src/main/java/org/apache/bcel/generic/RET.java
@@ -112,7 +112,7 @@ protected void initFromFile(final ByteSequence bytes, final boolean wide) throws
}
/**
- * Set index of local variable containg the return address
+ * Sets index of local variable containg the return address
*/
@Override
public final void setIndex(final @NonNegative int n) {
diff --git a/src/main/java/org/apache/bcel/generic/ReferenceType.java b/src/main/java/org/apache/bcel/generic/ReferenceType.java
index 9d37a3ca9a..30bcd45910 100644
--- a/src/main/java/org/apache/bcel/generic/ReferenceType.java
+++ b/src/main/java/org/apache/bcel/generic/ReferenceType.java
@@ -65,8 +65,8 @@ protected ReferenceType(final byte t, final @FieldDescriptor String s) {
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 java.lang.Object. However, the Java Language's
- * "instanceof" operator proves us wrong: "null" is not referring to an instance of java.lang.Object :)
+ * say all the objects referenced by Type.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) {
@@ -96,8 +96,8 @@ protected ReferenceType(final byte t, final @FieldDescriptor String s) {
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 java.lang.Object. However, the Java Language's
- * "instanceof" operator proves us wrong: "null" is not referring to an instance of java.lang.Object :)
+ * say all the objects referenced by Type.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} :)
*/
}
/* This code is from a bug report by Konstantin Shagin */
diff --git a/src/main/java/org/apache/bcel/generic/SWITCH.java b/src/main/java/org/apache/bcel/generic/SWITCH.java
index f0c9c128c0..27d2c586ef 100644
--- a/src/main/java/org/apache/bcel/generic/SWITCH.java
+++ b/src/main/java/org/apache/bcel/generic/SWITCH.java
@@ -95,7 +95,7 @@ public SWITCH(final int[] match, final InstructionHandle[] targets, final Instru
* @param maxGap maximum gap that may between case branches
*/
public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target, final @NonNegative int maxGap) {
- int[] matchClone = match.clone();
+ final int[] matchClone = match.clone();
final InstructionHandle[] targetsClone = targets.clone();
final int matchLength = match.length;
if (matchLength < 2) {
diff --git a/src/main/java/org/apache/bcel/generic/Select.java b/src/main/java/org/apache/bcel/generic/Select.java
index df9ad24191..832568f02a 100644
--- a/src/main/java/org/apache/bcel/generic/Select.java
+++ b/src/main/java/org/apache/bcel/generic/Select.java
@@ -298,7 +298,7 @@ final void setMatches(final int[] array) {
}
/**
- * Set branch target for 'i'th case
+ * Sets branch target for 'i'th case
*/
public void setTarget(final @NonNegative int i, final InstructionHandle target) { // TODO could be package-protected?
notifyTarget(targets[i], target, this);
@@ -324,8 +324,12 @@ public String toString(final boolean verbose) {
for (int i = 0; i < match_length; i++) {
String s = "null";
if (targets[i] != null) {
+ if (targets[i].getInstruction() == this) {
+ s = "";
+ } else {
s = targets[i].getInstruction().toString();
}
+ }
buf.append("(").append(match[i]).append(", ").append(s).append(" = {").append(indices[i]).append("})");
}
} else {
diff --git a/src/main/java/org/apache/bcel/generic/SimpleElementValueGen.java b/src/main/java/org/apache/bcel/generic/SimpleElementValueGen.java
index 0c2bee71ca..d178a10f66 100644
--- a/src/main/java/org/apache/bcel/generic/SimpleElementValueGen.java
+++ b/src/main/java/org/apache/bcel/generic/SimpleElementValueGen.java
@@ -166,7 +166,7 @@ public void dump(final DataOutputStream dos) throws IOException {
dos.writeShort(idx);
break;
default:
- throw new IllegalStateException("SimpleElementValueGen doesnt know how to write out type " + super.getElementValueType());
+ throw new IllegalStateException("SimpleElementValueGen doesn't know how to write out type " + super.getElementValueType());
}
}
@@ -186,7 +186,7 @@ public ElementValue getElementValue() {
public int getValueInt() {
if (super.getElementValueType() != PRIMITIVE_INT) {
- throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue");
+ throw new IllegalStateException("Don't call getValueString() on a non STRING ElementValue");
}
final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx);
return c.getBytes();
@@ -194,7 +194,7 @@ public int getValueInt() {
public String getValueString() {
if (super.getElementValueType() != STRING) {
- throw new IllegalStateException("Dont call getValueString() on a non STRING ElementValue");
+ throw new IllegalStateException("Don't call getValueString() on a non STRING ElementValue");
}
final ConstantUtf8 c = (ConstantUtf8) getConstantPool().getConstant(idx);
return c.getBytes();
diff --git a/src/main/java/org/apache/bcel/generic/Type.java b/src/main/java/org/apache/bcel/generic/Type.java
index da04c0c672..f955d2d7a3 100644
--- a/src/main/java/org/apache/bcel/generic/Type.java
+++ b/src/main/java/org/apache/bcel/generic/Type.java
@@ -23,7 +23,9 @@
import org.apache.bcel.Const;
import org.apache.bcel.classfile.ClassFormatException;
+import org.apache.bcel.classfile.InvalidMethodSignatureException;
import org.apache.bcel.classfile.Utility;
+import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.interning.qual.InternedDistinct;
@@ -36,7 +38,7 @@
import org.checkerframework.framework.qual.AnnotatedFor;
/**
- * Abstract super class for all possible java types, namely basic types such as int, object types like String and array
+ * Abstract super class for all possible Java types, namely basic types such as int, object types like String and array
* types, e.g. int[]
*/
@SuppressWarnings("interning") // sets constants
@@ -99,15 +101,15 @@ public static Type[] getArgumentTypes(final String signature) {
// Skip any type arguments to read argument declarations between '(' and ')'
index = signature.indexOf('(') + 1;
if (index <= 0) {
- throw new ClassFormatException("Invalid method signature: " + signature);
+ throw new InvalidMethodSignatureException(signature);
}
while (signature.charAt(index) != ')') {
vec.add(getType(signature.substring(index)));
- // corrected concurrent private static field acess
+ // corrected concurrent private static field access
index += unwrap(CONSUMED_CHARS); // update position
}
} catch (final StringIndexOutOfBoundsException e) { // Should never occur
- throw new ClassFormatException("Invalid method signature: " + signature, e);
+ throw new InvalidMethodSignatureException(signature, e);
}
final Type[] types = new Type[vec.size()];
vec.toArray(types);
@@ -121,7 +123,7 @@ public static Type[] getArgumentTypes(final String signature) {
// Skip any type arguments to read argument declarations between '(' and ')'
index = signature.indexOf('(') + 1;
if (index <= 0) {
- throw new ClassFormatException("Invalid method signature: " + signature);
+ throw new InvalidMethodSignatureException(signature);
}
while (signature.charAt(index) != ')') {
final int coded = getTypeSize(signature.substring(index));
@@ -129,7 +131,7 @@ public static Type[] getArgumentTypes(final String signature) {
index += consumed(coded);
}
} catch (final StringIndexOutOfBoundsException e) { // Should never occur
- throw new ClassFormatException("Invalid method signature: " + signature, e);
+ throw new InvalidMethodSignatureException(signature, e);
}
return res;
}
@@ -167,7 +169,7 @@ public static Type getReturnType(final String signature) {
final int index = signature.lastIndexOf(')') + 1;
return getType(signature.substring(index));
} catch (final StringIndexOutOfBoundsException e) { // Should never occur
- throw new ClassFormatException("Invalid method signature: " + signature, e);
+ throw new InvalidMethodSignatureException(signature, e);
}
}
@@ -188,7 +190,7 @@ public static String getSignature(final java.lang.reflect.Method meth) {
}
/**
- * Convert runtime java.lang.Class to BCEL Type object.
+ * Convert runtime {@link Class} to BCEL Type object.
*
* @param cls Java class
* @return corresponding Type object
@@ -196,7 +198,7 @@ public static String getSignature(final java.lang.reflect.Method meth) {
public static Type getType(final Class> cls) {
Objects.requireNonNull(cls, "cls");
/*
- * That's an amzingly easy case, because getName() returns the signature. That's what we would have liked anyway.
+ * That's an amazingly easy case, because getName() returns the signature. That's what we would have liked anyway.
*/
if (cls.isArray()) {
return getType(cls.getName());
@@ -249,7 +251,7 @@ public static Type getType(final Class> cls) {
public static @NonNull Type getType(final @FieldDescriptor String signature) throws StringIndexOutOfBoundsException {
final byte type = Utility.typeOfSignature(signature);
if (type <= Const.T_VOID) {
- // corrected concurrent private static field acess
+ // corrected concurrent private static field access
wrap(CONSUMED_CHARS, 1);
return BasicType.getType(type);
}
@@ -269,7 +271,7 @@ public static Type getType(final Class> cls) {
// Recurse, but just once, if the signature is ok
@SuppressWarnings("signature") // string manipulation: strip off array brackets and make recursive call
final Type t = getType(signature.substring(dim));
- // corrected concurrent private static field acess
+ // corrected concurrent private static field access
// consumed_chars += dim; // update counter - is replaced by
final int temp = unwrap(CONSUMED_CHARS) + dim;
wrap(CONSUMED_CHARS, temp);
@@ -277,7 +279,7 @@ public static Type getType(final Class> cls) {
}
/**
- * Convert runtime java.lang.Class[] to BCEL Type objects.
+ * Convert runtime {@code java.lang.Class[]} to BCEL Type objects.
*
* @param classes an array of runtime class objects
* @return array of corresponding Type objects
@@ -309,6 +311,24 @@ public static Type[] getTypes(final Class>[] classes) {
return encode(1, index + 1);
}
+ static String internalTypeNameToSignature(final String internalTypeName) {
+ if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, Const.SHORT_TYPE_NAMES)) {
+ return internalTypeName;
+ }
+ switch (internalTypeName.charAt(0)) {
+ case '[':
+ return internalTypeName;
+ case 'L':
+ case 'T':
+ if (internalTypeName.charAt(internalTypeName.length() - 1) == ';') {
+ return internalTypeName;
+ }
+ return 'L' + internalTypeName + ';';
+ default:
+ return 'L' + internalTypeName + ';';
+ }
+ }
+
static @NonNegative int size(final int coded) {
return coded & 3;
}
@@ -419,14 +439,6 @@ public Type normalizeForStackOrLocal() {
return this;
}
- /*
- * Currently only used by the ArrayType constructor. The signature has a complicated dependency on other parameter so
- * it's tricky to do it in a call to the super ctor.
- */
- void setSignature(final @FieldDescriptor String signature) {
- this.signature = signature;
- }
-
/**
* @return Type string, e.g. 'int[]'
*/
diff --git a/src/main/java/org/apache/bcel/generic/TypedInstruction.java b/src/main/java/org/apache/bcel/generic/TypedInstruction.java
index d4290b2a19..1c06851cb0 100644
--- a/src/main/java/org/apache/bcel/generic/TypedInstruction.java
+++ b/src/main/java/org/apache/bcel/generic/TypedInstruction.java
@@ -17,7 +17,7 @@
package org.apache.bcel.generic;
/**
- * Get the type associated with an instruction, int for ILOAD, or the type of the field of a PUTFIELD instruction, e.g..
+ * Gets the type associated with an instruction, int for ILOAD, or the type of the field of a PUTFIELD instruction, e.g..
*/
public interface TypedInstruction {
diff --git a/src/main/java/org/apache/bcel/generic/package-info.java b/src/main/java/org/apache/bcel/generic/package-info.java
new file mode 100644
index 0000000000..d2e117be7b
--- /dev/null
+++ b/src/main/java/org/apache/bcel/generic/package-info.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.
+ */
+
+/**
+ * Generic part of the Apache Byte Code Engineering Library (BCEL), classes to dynamically modify class objects
+ * and byte code instructions.
+ */
+package org.apache.bcel.generic;
diff --git a/src/main/java/org/apache/bcel/package-info.java b/src/main/java/org/apache/bcel/package-info.java
new file mode 100644
index 0000000000..371e358aca
--- /dev/null
+++ b/src/main/java/org/apache/bcel/package-info.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.
+ */
+
+/**
+ * Basic classes for the Apache Byte Code Engineering Library (BCEL) and constants defined by the
+ * JVM specification.
+ */
+package org.apache.bcel;
diff --git a/src/main/java/org/apache/bcel/util/BCELComparator.java b/src/main/java/org/apache/bcel/util/BCELComparator.java
index 0cc6a58b2d..98e5d50f3b 100644
--- a/src/main/java/org/apache/bcel/util/BCELComparator.java
+++ b/src/main/java/org/apache/bcel/util/BCELComparator.java
@@ -17,26 +17,27 @@
package org.apache.bcel.util;
/**
- * Used for BCEL comparison strategy
+ * Used for BCEL comparison strategy.
*
+ * @param What type we are comparing.
* @since 5.2
*/
-public interface BCELComparator {
+public interface BCELComparator {
/**
- * Compare two objects and return what THIS.equals(THAT) should return
+ * Compares two objects and return what a.equals(b) should return.
*
- * @param THIS
- * @param THAT
- * @return true if and only if THIS equals THAT
+ * @param a an object.
+ * @param b an object to be compared with {@code a} for equality.
+ * @return {@code true} if the arguments are equal to each other and {@code false} otherwise.
*/
- boolean equals(Object THIS, Object THAT);
+ boolean equals(T a, T b);
/**
- * Return hashcode for THIS.hashCode()
+ * Gets the hash code for o.hashCode()
*
- * @param THIS
- * @return hashcode for THIS.hashCode()
+ * @param o
+ * @return hash code for o.hashCode()
*/
- int hashCode(Object THIS);
+ int hashCode(T o);
}
diff --git a/src/main/java/org/apache/bcel/util/BCELFactory.java b/src/main/java/org/apache/bcel/util/BCELFactory.java
index 07a7fa59bb..37ec5fa344 100644
--- a/src/main/java/org/apache/bcel/util/BCELFactory.java
+++ b/src/main/java/org/apache/bcel/util/BCELFactory.java
@@ -60,7 +60,7 @@
*
* @see BCELifier
*/
-class BCELFactory extends EmptyVisitor {
+final class BCELFactory extends EmptyVisitor {
private static final String CONSTANT_PREFIX = Const.class.getSimpleName() + ".";
private final MethodGen methodGen;
diff --git a/src/main/java/org/apache/bcel/util/BCELifier.java b/src/main/java/org/apache/bcel/util/BCELifier.java
index 8295dbeee7..80e27cdcaa 100644
--- a/src/main/java/org/apache/bcel/util/BCELifier.java
+++ b/src/main/java/org/apache/bcel/util/BCELifier.java
@@ -26,16 +26,21 @@
import org.apache.bcel.Const;
import org.apache.bcel.Repository;
import org.apache.bcel.classfile.ClassParser;
+import org.apache.bcel.classfile.Code;
import org.apache.bcel.classfile.ConstantValue;
import org.apache.bcel.classfile.ExceptionTable;
import org.apache.bcel.classfile.Field;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;
+import org.apache.bcel.classfile.StackMap;
+import org.apache.bcel.classfile.StackMapEntry;
+import org.apache.bcel.classfile.StackMapType;
import org.apache.bcel.classfile.Utility;
import org.apache.bcel.generic.ArrayType;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.MethodGen;
import org.apache.bcel.generic.Type;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
/**
@@ -307,6 +312,13 @@ public void visitMethod(final Method method) {
printWriter.println("\");");
}
}
+ final Code code = method.getCode();
+ if (code != null) {
+ final StackMap stackMap = code.getStackMap();
+ if (stackMap != null) {
+ stackMap.accept(this);
+ }
+ }
printWriter.println();
final BCELFactory factory = new BCELFactory(mg, printWriter);
factory.start();
@@ -315,4 +327,78 @@ public void visitMethod(final Method method) {
printWriter.println(" _cg.addMethod(method.getMethod());");
printWriter.println(" il.dispose();");
}
+
+ @Override
+ public void visitStackMap(final StackMap stackMap) {
+ super.visitStackMap(stackMap);
+ printWriter.print(" method.addCodeAttribute(");
+ printWriter.print("new StackMap(_cp.addUtf8(\"");
+ printWriter.print(stackMap.getName());
+ printWriter.print("\"), ");
+ printWriter.print(stackMap.getLength());
+ printWriter.print(", ");
+ printWriter.print("new StackMapEntry[] {");
+ final StackMapEntry[] table = stackMap.getStackMap();
+ for (int i = 0; i < table.length; i++) {
+ table[i].accept(this);
+ if (i < table.length - 1) {
+ printWriter.print(", ");
+ } else {
+ printWriter.print(" }");
+ }
+ }
+ printWriter.print(", _cp.getConstantPool())");
+ printWriter.println(");");
+ }
+
+ @Override
+ public void visitStackMapEntry(final StackMapEntry stackMapEntry) {
+ super.visitStackMapEntry(stackMapEntry);
+ printWriter.print("new StackMapEntry(");
+ printWriter.print(stackMapEntry.getFrameType());
+ printWriter.print(", ");
+ printWriter.print(stackMapEntry.getByteCodeOffset());
+ printWriter.print(", ");
+ visitStackMapTypeArray(stackMapEntry.getTypesOfLocals());
+ printWriter.print(", ");
+ visitStackMapTypeArray(stackMapEntry.getTypesOfStackItems());
+ printWriter.print(", _cp.getConstantPool())");
+ }
+
+ /**
+ * Visits a {@link StackMapType} object.
+ * @param stackMapType object to visit
+ * @since 6.7.1
+ */
+ @Override
+ public void visitStackMapType(final StackMapType stackMapType) {
+ super.visitStackMapType(stackMapType);
+ printWriter.print("new StackMapType((byte)");
+ printWriter.print(stackMapType.getType());
+ printWriter.print(", ");
+ if (stackMapType.hasIndex()) {
+ printWriter.print("_cp.addClass(\"");
+ printWriter.print(stackMapType.getClassName());
+ printWriter.print("\")");
+ } else {
+ printWriter.print("-1");
+ }
+ printWriter.print(", _cp.getConstantPool())");
+ }
+
+ private void visitStackMapTypeArray(final StackMapType[] types) {
+ if (ArrayUtils.isEmpty(types)) {
+ printWriter.print("null"); // null translates to StackMapType.EMPTY_ARRAY
+ } else {
+ printWriter.print("new StackMapType[] {");
+ for (int i = 0; i < types.length; i++) {
+ types[i].accept(this);
+ if (i < types.length - 1) {
+ printWriter.print(", ");
+ } else {
+ printWriter.print(" }");
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/org/apache/bcel/util/Class2HTML.java b/src/main/java/org/apache/bcel/util/Class2HTML.java
index 3ad969e88a..b67748e03f 100644
--- a/src/main/java/org/apache/bcel/util/Class2HTML.java
+++ b/src/main/java/org/apache/bcel/util/Class2HTML.java
@@ -115,7 +115,7 @@ public static void main(final String[] argv) throws IOException {
if (zipFile == null) {
parser = new ClassParser(fileName[i]); // Create parser object from file
} else {
- parser = new ClassParser(zipFile, fileName[i]); // Create parser object from zip file
+ parser = new ClassParser(zipFile, fileName[i]); // Create parser object from ZIP file
}
javaClass = parser.parse();
new Class2HTML(javaClass, dir);
diff --git a/src/main/java/org/apache/bcel/util/ClassPath.java b/src/main/java/org/apache/bcel/util/ClassPath.java
index d1beb13895..9bb27c8936 100644
--- a/src/main/java/org/apache/bcel/util/ClassPath.java
+++ b/src/main/java/org/apache/bcel/util/ClassPath.java
@@ -151,7 +151,7 @@ public interface ClassFile {
/**
* @return base path of found class, i.e. class is contained relative to that path, which may either denote a directory,
- * or zip file
+ * or ZIP file
*/
String getBase();
@@ -177,7 +177,7 @@ public interface ClassFile {
long getTime();
}
- private static class Dir extends AbstractPathEntry {
+ private static final class Dir extends AbstractPathEntry {
private final String dir;
@@ -260,7 +260,7 @@ public String toString() {
}
}
- private static class Jar extends AbstractZip {
+ private static final class Jar extends AbstractZip {
Jar(final ZipFile zip) {
super(zip);
@@ -273,7 +273,7 @@ protected String toEntryName(final String name, final String suffix) {
}
- private static class JrtModule extends AbstractPathEntry {
+ private static final class JrtModule extends AbstractPathEntry {
private final Path modulePath;
@@ -356,7 +356,7 @@ public String toString() {
}
- private static class JrtModules extends AbstractPathEntry {
+ private static final class JrtModules extends AbstractPathEntry {
private final @Owning ModularRuntimeImage modularRuntimeImage;
private final @Owning JrtModule[] modules;
@@ -426,7 +426,7 @@ public String toString() {
}
- private static class Module extends AbstractZip {
+ private static final class Module extends AbstractZip {
Module(final ZipFile zip) {
super(zip);
@@ -646,7 +646,7 @@ public byte[] getBytes(final String name, final String suffix) throws IOExceptio
/**
* @param name fully qualified file name, e.g. java/lang/String
* @param suffix file name ends with suff, e.g. .java
- * @return class file for the java class
+ * @return class file for the Java class
* @throws IOException if an I/O error occurs.
*/
public @Nullable ClassFile getClassFile(final String name, final String suffix) throws IOException {
diff --git a/src/main/java/org/apache/bcel/util/ClassVector.java b/src/main/java/org/apache/bcel/util/ClassVector.java
index 0ecb0411ee..e53b406129 100644
--- a/src/main/java/org/apache/bcel/util/ClassVector.java
+++ b/src/main/java/org/apache/bcel/util/ClassVector.java
@@ -34,8 +34,9 @@
public class ClassVector implements Serializable {
private static final long serialVersionUID = 5600397075672780806L;
+
@Deprecated
- protected List vec = new ArrayList<>();
+ protected transient List vec = new ArrayList<>();
public void addElement(final JavaClass clazz) {
vec.add(clazz);
@@ -45,6 +46,11 @@ public JavaClass elementAt(final @NonNegative int index) {
return vec.get(index);
}
+ @SuppressWarnings("unused") // SE_TRANSIENT_FIELD_NOT_RESTORED
+ private void readObjectNoData() {
+ vec = new ArrayList<>();
+ }
+
public void removeElementAt(final @NonNegative int index) {
vec.remove(index);
}
diff --git a/src/main/java/org/apache/bcel/util/CodeHTML.java b/src/main/java/org/apache/bcel/util/CodeHTML.java
index fbe038c8fb..b190656db9 100644
--- a/src/main/java/org/apache/bcel/util/CodeHTML.java
+++ b/src/main/java/org/apache/bcel/util/CodeHTML.java
@@ -545,7 +545,7 @@ private void writeMethod(@UnknownInitialization(CodeHTML.class) CodeHTML this, f
final String str = codeToHTML(stream, methodNumber);
String anchor = "";
/*
- * Set an anchor mark if this line is targetted by a goto, jsr, etc. Defining an anchor for every line is very
+ * Sets an anchor mark if this line is targetted by a goto, jsr, etc. Defining an anchor for every line is very
* inefficient!
*/
if (gotoSet.get(offset)) {
diff --git a/src/main/java/org/apache/bcel/util/InstructionFinder.java b/src/main/java/org/apache/bcel/util/InstructionFinder.java
index 4c0af58770..40578c05c1 100644
--- a/src/main/java/org/apache/bcel/util/InstructionFinder.java
+++ b/src/main/java/org/apache/bcel/util/InstructionFinder.java
@@ -372,7 +372,7 @@ public final Iterator search(final String pattern, final In
// }
// private static final String pattern2string( String pattern, boolean make_string ) {
-// StringBuffer buf = new StringBuffer();
+// StringBuilder buf = new StringBuilder();
// for (int i = 0; i < pattern.length(); i++) {
// char ch = pattern.charAt(i);
// if (ch >= OFFSET) {
diff --git a/src/main/java/org/apache/bcel/util/JavaWrapper.java b/src/main/java/org/apache/bcel/util/JavaWrapper.java
index d6213659af..895b362440 100644
--- a/src/main/java/org/apache/bcel/util/JavaWrapper.java
+++ b/src/main/java/org/apache/bcel/util/JavaWrapper.java
@@ -54,7 +54,7 @@ private static java.lang.ClassLoader getClassLoader() {
throw new IllegalStateException("The property 'bcel.classloader' must be defined");
}
try {
- return (java.lang.ClassLoader) Class.forName(s).newInstance();
+ return (java.lang.ClassLoader) Class.forName(s).getConstructor().newInstance();
} catch (final Exception e) {
throw new IllegalStateException(e.toString(), e);
}
diff --git a/src/main/java/org/apache/bcel/util/package-info.java b/src/main/java/org/apache/bcel/util/package-info.java
new file mode 100644
index 0000000000..b4f9c4baed
--- /dev/null
+++ b/src/main/java/org/apache/bcel/util/package-info.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+/**
+ * Utility classes for the Apache Byte Code Engineering Library (BCEL), namely:
+ *
+ * - Collection classes for JavaClass objects
+ * - A converter for class files to HTML
+ * - A tool to find instructions patterns via regular expressions
+ * - A class to find classes as defined in the CLASSPATH
+ * - A class loader that allows to create classes at run time
+ *
+ */
+package org.apache.bcel.util;
diff --git a/src/main/java/org/apache/bcel/verifier/GraphicalVerifier.java b/src/main/java/org/apache/bcel/verifier/GraphicalVerifier.java
index 115055e0b4..331eb5f979 100644
--- a/src/main/java/org/apache/bcel/verifier/GraphicalVerifier.java
+++ b/src/main/java/org/apache/bcel/verifier/GraphicalVerifier.java
@@ -40,7 +40,7 @@ public static void main(final String[] args) {
new GraphicalVerifier();
}
- /** Constructor. */
+ /** Constructs a new instance. */
public GraphicalVerifier() {
final VerifierAppFrame frame = new VerifierAppFrame();
// Frames �berpr�fen, die voreingestellte Gr��e haben
diff --git a/src/main/java/org/apache/bcel/verifier/VerifierAppFrame.java b/src/main/java/org/apache/bcel/verifier/VerifierAppFrame.java
index e122a8bea2..e8482cc2ab 100644
--- a/src/main/java/org/apache/bcel/verifier/VerifierAppFrame.java
+++ b/src/main/java/org/apache/bcel/verifier/VerifierAppFrame.java
@@ -90,7 +90,7 @@ public class VerifierAppFrame extends JFrame {
private final JMenuItem whatisMenuItem = new JMenuItem();
private final JMenuItem aboutMenuItem = new JMenuItem();
- /** Constructor. */
+ /** Constructs a new instance. */
public VerifierAppFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
@@ -100,11 +100,11 @@ public VerifierAppFrame() {
}
}
- void aboutMenuItem_actionPerformed(final ActionEvent e) {
+ void aboutMenuItemActionPerformed(final ActionEvent e) {
JOptionPane.showMessageDialog(this, Verifier.BANNER, Verifier.NAME, JOptionPane.INFORMATION_MESSAGE);
}
- synchronized void classNamesJList_valueChanged(final ListSelectionEvent e) {
+ synchronized void classNamesJListValueChanged(final ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
@@ -148,7 +148,7 @@ private void jbInit() {
jScrollPane1.getViewport().setBackground(Color.red);
messagesScrollPane.getViewport().setBackground(Color.red);
messagesScrollPane.setPreferredSize(new Dimension(10, 10));
- classNamesJList.addListSelectionListener(this::classNamesJList_valueChanged);
+ classNamesJList.addListSelectionListener(this::classNamesJListValueChanged);
classNamesJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jScrollPane3.setBorder(BorderFactory.createLineBorder(Color.black));
jScrollPane3.setPreferredSize(new Dimension(100, 100));
@@ -166,16 +166,16 @@ private void jbInit() {
messagesTextPane.setEditable(false);
newFileMenuItem.setText("New...");
newFileMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(78, InputEvent.CTRL_MASK, true));
- newFileMenuItem.addActionListener(this::newFileMenuItem_actionPerformed);
+ newFileMenuItem.addActionListener(this::newFileMenuItemActionPerformed);
pass3aTextPane.setEditable(false);
pass3bTextPane.setEditable(false);
pass3aJList.addListSelectionListener(this::pass3aJList_valueChanged);
pass3bJList.addListSelectionListener(this::pass3bJList_valueChanged);
jMenu2.setText("Help");
whatisMenuItem.setText("What is...");
- whatisMenuItem.addActionListener(this::whatisMenuItem_actionPerformed);
+ whatisMenuItem.addActionListener(this::whatisMenuItemActionPerformed);
aboutMenuItem.setText("About");
- aboutMenuItem.addActionListener(this::aboutMenuItem_actionPerformed);
+ aboutMenuItem.addActionListener(this::aboutMenuItemActionPerformed);
jSplitPane2.add(messagesPanel, JSplitPane.BOTTOM);
messagesPanel.add(messagesScrollPane, null);
messagesScrollPane.getViewport().add(messagesTextPane, null);
@@ -210,7 +210,7 @@ private void jbInit() {
jSplitPane4.setDividerLocation(150);
}
- void newFileMenuItem_actionPerformed(final ActionEvent e) {
+ void newFileMenuItemActionPerformed(final ActionEvent e) {
final String className = JOptionPane.showInputDialog("Please enter the fully qualified name of a class or interface to verify:");
if (className == null || className.isEmpty()) {
return;
@@ -342,7 +342,7 @@ private void verify() throws ClassNotFoundException {
setTitle(currentClass + " - " + Verifier.NAME);
}
- void whatisMenuItem_actionPerformed(final ActionEvent e) {
+ void whatisMenuItemActionPerformed(final ActionEvent e) {
JOptionPane.showMessageDialog(this,
"The upper four boxes to the right reflect verification passes according to"
+ " The Java Virtual Machine Specification.\nThese are (in that order):"
diff --git a/src/main/java/org/apache/bcel/verifier/VerifyDialog.java b/src/main/java/org/apache/bcel/verifier/VerifyDialog.java
index 4273701fe0..b835fc83a5 100644
--- a/src/main/java/org/apache/bcel/verifier/VerifyDialog.java
+++ b/src/main/java/org/apache/bcel/verifier/VerifyDialog.java
@@ -46,8 +46,8 @@
*/
public class VerifyDialog extends JDialog {
- /** Machine-generated. */
- class IvjEventHandler implements ActionListener {
+ /** Machine-generated, made final. */
+ final class IvjEventHandler implements ActionListener {
@Override
@SuppressWarnings("interning") // machine-generated GUI code
@@ -68,6 +68,7 @@ public void actionPerformed(final ActionEvent e) {
}
private static final long serialVersionUID = -6374807677043142313L;
+
/**
* This field is here to count the number of open VerifyDialog instances so the JVM can be exited afer every Dialog had
* been closed.
@@ -178,9 +179,9 @@ public VerifyDialog(final Frame owner, final String title, final boolean modal)
}
/**
- * Use this constructor if you want a possibility to verify other class files than java.lang.Object.
+ * Use this constructor if you want a possibility to verify other class files than {@link Object}.
*
- * @param fullyQualifiedClassName java.lang.String
+ * @param fullyQualifiedClassName "java.lang.String"
*/
public VerifyDialog(String fullyQualifiedClassName) {
final int dotclasspos = fullyQualifiedClassName.lastIndexOf(JavaClass.EXTENSION);
diff --git a/src/main/java/org/apache/bcel/verifier/exc/package-info.java b/src/main/java/org/apache/bcel/verifier/exc/package-info.java
new file mode 100644
index 0000000000..e56842d938
--- /dev/null
+++ b/src/main/java/org/apache/bcel/verifier/exc/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * Exception classes used by JustIce, mostly used internally. You don't need to bother with them.
+ * Package Specification
+ *
+ * Contained in this package are Exception classes for use with the JustIce verifier.
+ *
+ */
+package org.apache.bcel.verifier.exc;
diff --git a/src/main/java/org/apache/bcel/verifier/package-info.java b/src/main/java/org/apache/bcel/verifier/package-info.java
new file mode 100644
index 0000000000..2e16a1848c
--- /dev/null
+++ b/src/main/java/org/apache/bcel/verifier/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * BCEL's verifier JustIce is there to help you dump correct Java class files created or modified with BCEL.
+ * Package Specification
+ *
+ * This is the top-level package of the JustIce verifier. To actually use it, have a look at the VerifierFactory and Verifier classes.
+ *
+ */
+package org.apache.bcel.verifier;
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 46208c12bf..dac1c1ac94 100644
--- a/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
+++ b/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
@@ -167,8 +167,8 @@ public void visitCode(final Code obj) {// vmspec2 4.7.3
}
if (!(carrier.predecessor() instanceof Method)) {
- addMessage(
- "Code attribute '" + tostring(obj) + "' is not declared in a method_info structure but in '" + carrier.predecessor() + "'. Ignored.");
+ addMessage("Code attribute '" + tostring(obj) + "' is not declared in a method_info structure but in '" + carrier.predecessor()
+ + "'. Ignored.");
return;
}
final Method m = (Method) carrier.predecessor(); // we can assume this method was visited before;
@@ -278,8 +278,8 @@ public void visitCode(final Code obj) {// vmspec2 4.7.3
final String lvtname = ((ConstantUtf8) cp.getConstant(lvt.getNameIndex())).getBytes();
if (!lvtname.equals("LocalVariableTable")) {
- throw new ClassConstraintException(
- "The LocalVariableTable attribute '" + tostring(lvt) + "' is not correctly named 'LocalVariableTable' but '" + lvtname + "'.");
+ throw new ClassConstraintException("The LocalVariableTable attribute '" + tostring(lvt)
+ + "' is not correctly named 'LocalVariableTable' but '" + lvtname + "'.");
}
// In JustIce, the check for correct offsets into the code array is delayed to Pass 3a.
@@ -302,9 +302,9 @@ public void visitCode(final Code obj) {// vmspec2 4.7.3
}
final @NonNegative int localindex = localvariable.getIndex();
if ((t == Type.LONG || t == Type.DOUBLE ? localindex + 1 : localindex) >= obj.getMaxLocals()) {
- throw new ClassConstraintException(
- "LocalVariableTable attribute '" + tostring(lvt) + "' references a LocalVariable '" + tostring(localvariable)
- + "' with an index that exceeds the surrounding Code attribute's max_locals value of '" + obj.getMaxLocals() + "'.");
+ throw new ClassConstraintException("LocalVariableTable attribute '" + tostring(lvt) + "' references a LocalVariable '"
+ + tostring(localvariable) + "' with an index that exceeds the surrounding Code attribute's max_locals value of '"
+ + obj.getMaxLocals() + "'.");
}
try {
@@ -1127,7 +1127,7 @@ public void visitConstantMethodref(final ConstantMethodref obj) {
* called "XXX". JustIce cannot repair this; please note that existing verifiers at this time even fail to detect
* missing InnerClasses attributes in pass 2.
*/
- private static class InnerClassDetector extends EmptyVisitor {
+ private static final class InnerClassDetector extends EmptyVisitor {
private boolean hasInnerClass;
private final JavaClass jc;
private final ConstantPool cp;
@@ -1331,7 +1331,7 @@ public VerificationResult do_verify() {
/**
* Ensures that every class has a super class and that final classes are not subclassed. This means, the class
- * this Pass2Verifier operates on has proper super classes (transitively) up to java.lang.Object. The reason for really
+ * this Pass2Verifier operates on has proper super classes (transitively) up to {@link Object}. The reason for really
* loading (and Pass1-verifying) all of those classes here is that we need them in Pass2 anyway to verify no final
* methods are overridden (that could be declared anywhere in the ancestor hierarchy).
*
diff --git a/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java b/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
index d8e1f8e2f9..97fd9f169d 100644
--- a/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
+++ b/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
@@ -25,12 +25,15 @@
import org.apache.bcel.classfile.Code;
import org.apache.bcel.classfile.CodeException;
import org.apache.bcel.classfile.Constant;
+import org.apache.bcel.classfile.ConstantCP;
import org.apache.bcel.classfile.ConstantClass;
import org.apache.bcel.classfile.ConstantDouble;
+import org.apache.bcel.classfile.ConstantDynamic;
import org.apache.bcel.classfile.ConstantFieldref;
import org.apache.bcel.classfile.ConstantFloat;
import org.apache.bcel.classfile.ConstantInteger;
import org.apache.bcel.classfile.ConstantInterfaceMethodref;
+import org.apache.bcel.classfile.ConstantInvokeDynamic;
import org.apache.bcel.classfile.ConstantLong;
import org.apache.bcel.classfile.ConstantMethodref;
import org.apache.bcel.classfile.ConstantNameAndType;
@@ -115,7 +118,7 @@ public final class Pass3aVerifier extends PassVerifier {
/**
* This visitor class does the actual checking for the instruction operand's constraints.
*/
- private class InstOperandConstraintVisitor extends org.apache.bcel.generic.EmptyVisitor {
+ private final class InstOperandConstraintVisitor extends org.apache.bcel.generic.EmptyVisitor {
/** The ConstantPoolGen instance this Visitor operates on. */
private final ConstantPoolGen constantPoolGen;
@@ -324,60 +327,10 @@ public void visitFieldInstruction(final FieldInstruction o) {
final String fieldName = o.getFieldName(constantPoolGen);
final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName());
- Field[] fields = jc.getFields();
- Field f = null;
- for (final Field field : fields) {
- if (field.getName().equals(fieldName)) {
- final Type fType = Type.getType(field.getSignature());
- final Type oType = o.getType(constantPoolGen);
- /*
- * TODO: Check if assignment compatibility is sufficient. What does Sun do?
- */
- if (fType.equals(oType)) {
- f = field;
- break;
- }
- }
- }
- if (f == null) {
- final JavaClass[] superclasses = jc.getSuperClasses();
- outer: for (final JavaClass superclass : superclasses) {
- fields = superclass.getFields();
- for (final Field field : fields) {
- if (field.getName().equals(fieldName)) {
- final Type fType = Type.getType(field.getSignature());
- final Type oType = o.getType(constantPoolGen);
- if (fType.equals(oType)) {
- f = field;
- if ((f.getAccessFlags() & (Const.ACC_PUBLIC | Const.ACC_PROTECTED)) == 0) {
- f = null;
- }
- break outer;
- }
- }
- }
- }
+ final Field f = jc.findField(fieldName, o.getType(constantPoolGen));
if (f == null) {
constraintViolated(o, "Referenced field '" + fieldName + "' does not exist in class '" + jc.getClassName() + "'.");
}
- } else {
- /*
- * TODO: Check if assignment compatibility is sufficient. What does Sun do?
- */
- Type.getType(f.getSignature());
- o.getType(constantPoolGen);
-// Type f_type = Type.getType(f.getSignature());
-// Type o_type = o.getType(cpg);
-
- // Argh. Sun's implementation allows us to have multiple fields of
- // the same name but with a different signature.
- // if (! f_type.equals(o_type)) {
- // constraintViolated(o,
- // "Referenced field '"+field_name+"' has type '"+f_type+"' instead of '"+o_type+"' as expected.");
- // }
-
- /* TODO: Check for access modifiers here. */
- }
} catch (final ClassNotFoundException e) {
// FIXME: maybe not the best way to handle this
throw new AssertionViolatedException("Missing class: " + e, e);
@@ -418,14 +371,7 @@ public void visitGETSTATIC(final GETSTATIC o) {
try {
final String fieldName = o.getFieldName(constantPoolGen);
final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName());
- final Field[] fields = jc.getFields();
- Field f = null;
- for (final Field field : fields) {
- if (field.getName().equals(fieldName)) {
- f = field;
- break;
- }
- }
+ final Field f = jc.findField(fieldName, o.getType(constantPoolGen));
if (f == null) {
throw new AssertionViolatedException("Field '" + fieldName + "' not found in " + jc.getClassName());
}
@@ -505,8 +451,8 @@ public void visitInvokeInstruction(final InvokeInstruction o) {
}
} else {
final Constant c = constantPoolGen.getConstant(o.getIndex());
- if (!(c instanceof ConstantInterfaceMethodref)) {
- constraintViolated(o, "Indexing a constant that's not a CONSTANT_InterfaceMethodref but a '" + tostring(c) + "'.");
+ if (!(c instanceof ConstantInterfaceMethodref) && !(c instanceof ConstantInvokeDynamic)) {
+ constraintViolated(o, "Indexing a constant that's not a CONSTANT_InterfaceMethodref/InvokeDynamic but a '" + tostring(c) + "'.");
}
// TODO: From time to time check if BCEL allows to detect if the
// 'count' operand is consistent with the information in the
@@ -514,7 +460,7 @@ public void visitInvokeInstruction(final InvokeInstruction o) {
// By now, BCEL hides those two operands because they're superfluous.
// Invoked method must not be or
- final ConstantNameAndType cnat = (ConstantNameAndType) constantPoolGen.getConstant(((ConstantInterfaceMethodref) c).getNameAndTypeIndex());
+ final ConstantNameAndType cnat = (ConstantNameAndType) constantPoolGen.getConstant(((ConstantCP) c).getNameAndTypeIndex());
final String name = ((ConstantUtf8) constantPoolGen.getConstant(cnat.getNameIndex())).getBytes();
if (name.equals(Const.CONSTRUCTOR_NAME)) {
constraintViolated(o, "Method to invoke must not be '" + Const.CONSTRUCTOR_NAME + "'.");
@@ -666,7 +612,12 @@ public void visitINVOKEVIRTUAL(final INVOKEVIRTUAL o) {
// INVOKEVIRTUAL is an InvokeInstruction, the argument and return types are resolved/verified,
// too. So are the allowed method names.
final String className = o.getClassName(constantPoolGen);
- final JavaClass jc = Repository.lookupClass(className);
+ JavaClass jc;
+ if (className.charAt(0) == '[') { // array type, e.g. invoke can be someArray.clone()
+ jc = Repository.lookupClass("java.lang.Object");
+ } else {
+ jc = Repository.lookupClass(className);
+ }
final Method m = getMethodRecursive(jc, o);
if (m == null) {
constraintViolated(o, "Referenced method '" + o.getMethodName(constantPoolGen) + "' with expected signature '"
@@ -705,9 +656,10 @@ public void visitLDC(final LDC ldc) {
final Constant c = constantPoolGen.getConstant(ldc.getIndex());
if (c instanceof ConstantClass) {
addMessage("Operand of LDC or LDC_W is CONSTANT_Class '" + tostring(c) + "' - this is only supported in JDK 1.5 and higher.");
- } else if (!(c instanceof ConstantInteger || c instanceof ConstantFloat || c instanceof ConstantString)) {
+ } else if (!(c instanceof ConstantInteger || c instanceof ConstantFloat || c instanceof ConstantString || c instanceof ConstantDynamic)) {
constraintViolated(ldc,
- "Operand of LDC or LDC_W must be one of CONSTANT_Integer, CONSTANT_Float or CONSTANT_String, but is '" + tostring(c) + "'.");
+ "Operand of LDC or LDC_W must be one of CONSTANT_Integer, CONSTANT_Float, CONSTANT_String or CONSTANT_Dynamic but is '"
+ + tostring(c) + "'.");
}
}
@@ -861,14 +813,7 @@ public void visitPUTSTATIC(final PUTSTATIC o) {
try {
final String fieldName = o.getFieldName(constantPoolGen);
final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName());
- final Field[] fields = jc.getFields();
- Field f = null;
- for (final Field field : fields) {
- if (field.getName().equals(fieldName)) {
- f = field;
- break;
- }
- }
+ final Field f = jc.findField(fieldName, o.getType(constantPoolGen));
if (f == null) {
throw new AssertionViolatedException("Field '" + fieldName + "' not found in " + jc.getClassName());
}
diff --git a/src/main/java/org/apache/bcel/verifier/statics/package-info.java b/src/main/java/org/apache/bcel/verifier/statics/package-info.java
new file mode 100644
index 0000000000..db59cfa962
--- /dev/null
+++ b/src/main/java/org/apache/bcel/verifier/statics/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+/**
+ * PassVerifier classes used internally by JustIce. You don't need to bother with them.
+ * Package Specification
+ *
+ * Contained in this package are PassVerifier classes for use with the JustIce verifier. Only the passes performing what Sun calls 'static constraints' have
+ * PassVerifier classes here.
+ *
+ */
+package org.apache.bcel.verifier.statics;
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 896e5c0218..72f295e648 100644
--- a/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java
+++ b/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java
@@ -46,10 +46,10 @@ public class ControlFlowGraph {
/**
* Objects of this class represent a node in a ControlFlowGraph. These nodes are instructions, not basic blocks.
*/
- private class InstructionContextImpl implements InstructionContext {
+ private final class InstructionContextImpl implements InstructionContext {
/**
- * The TAG field is here for external temporary flagging, such as graph colouring.
+ * The TAG field is here for external temporary flagging, such as graph coloring.
*
* @see #getTag()
* @see #setTag(int)
@@ -262,9 +262,6 @@ public Frame getInFrame() {
return org.getClone();
}
- /*
- * Fulfils the contract of InstructionContext.getInstruction().
- */
@Override
@Pure
public InstructionHandle getInstruction() {
@@ -291,13 +288,11 @@ public Frame getOutFrame(final ArrayList execChain) {
return org.getClone();
}
- /* Satisfies InstructionContext.getSuccessors(). */
@Override
public InstructionContext[] getSuccessors() {
return contextsOf(_getSuccessors());
}
- /* Satisfies InstructionContext.getTag(). */
@Override
@Pure
public int getTag() {
diff --git a/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java b/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java
index 910498f9e9..14923031a6 100644
--- a/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java
+++ b/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java
@@ -22,7 +22,7 @@
import org.checkerframework.dataflow.qual.Pure;
/**
- * This class represents an exception handler; that is, an ObjectType representing a subclass of java.lang.Throwable and
+ * This class represents an exception handler; that is, an ObjectType representing a subclass of {@link Throwable} and
* the instruction the handler starts off (represented by an InstructionContext).
*/
public class ExceptionHandler {
diff --git a/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java b/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java
index be1cdb1270..0a9dbab8c8 100644
--- a/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java
+++ b/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java
@@ -41,7 +41,7 @@ public class ExceptionHandlers {
private final Map> exceptionHandlers;
/**
- * Constructor. Creates a new ExceptionHandlers instance.
+ * Constructs a new ExceptionHandlers instance.
*/
public ExceptionHandlers(final MethodGen mg) {
exceptionHandlers = new HashMap<>();
diff --git a/src/main/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java b/src/main/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java
index 5fc399d121..3cc1565e11 100644
--- a/src/main/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java
+++ b/src/main/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java
@@ -20,6 +20,7 @@
import org.apache.bcel.classfile.Constant;
import org.apache.bcel.classfile.ConstantClass;
import org.apache.bcel.classfile.ConstantDouble;
+import org.apache.bcel.classfile.ConstantDynamic;
import org.apache.bcel.classfile.ConstantFloat;
import org.apache.bcel.classfile.ConstantInteger;
import org.apache.bcel.classfile.ConstantLong;
@@ -70,7 +71,7 @@ public class ExecutionVisitor extends EmptyVisitor {
private ConstantPoolGen cpg;
/**
- * Constructor. Constructs a new instance of this class.
+ * Constructs a new instance of this class.
*/
public ExecutionVisitor() {
}
@@ -1055,6 +1056,9 @@ public void visitLDC(final LDC o) {
if (c instanceof ConstantClass) {
stack().push(Type.CLASS);
}
+ if (c instanceof ConstantDynamic) {
+ stack().push(Type.OBJECT);
+ }
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
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 4cd699ac7d..0fa6e412f0 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 java.lang.Cloneable and java.io.Serializable and they extend java.lang.Object.
+ * implement {@link Cloneable} and {@link java.io.Serializable} and they extend {@link Object}.
*/
public class GenericArray implements Cloneable, Serializable {
diff --git a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
index 681cb9c5d6..5156a0ebef 100644
--- a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
+++ b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
@@ -21,6 +21,7 @@
import org.apache.bcel.classfile.Constant;
import org.apache.bcel.classfile.ConstantClass;
import org.apache.bcel.classfile.ConstantDouble;
+import org.apache.bcel.classfile.ConstantDynamic;
import org.apache.bcel.classfile.ConstantFieldref;
import org.apache.bcel.classfile.ConstantFloat;
import org.apache.bcel.classfile.ConstantInteger;
@@ -920,21 +921,7 @@ public void visitFieldInstruction(final FieldInstruction o) {
private Field visitFieldInstructionInternals(final FieldInstruction o) throws ClassNotFoundException {
final String fieldName = o.getFieldName(cpg);
final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName());
- final Field[] fields = jc.getFields();
- Field f = null;
- for (final Field field : fields) {
- if (field.getName().equals(fieldName)) {
- final Type fType = Type.getType(field.getSignature());
- final Type oType = o.getType(cpg);
- /*
- * TODO: Check if assignment compatibility is sufficient. What does Sun do?
- */
- if (fType.equals(oType)) {
- f = field;
- break;
- }
- }
- }
+ final Field f = jc.findField(fieldName, o.getType(cpg));
if (f == null) {
throw new AssertionViolatedException("Field '" + fieldName + "' not found in " + jc.getClassName());
}
@@ -946,7 +933,7 @@ private Field visitFieldInstructionInternals(final FieldInstruction o) throws Cl
}
if (t instanceof ReferenceType) {
if (value instanceof ReferenceType) {
- ReferenceType rValue = (ReferenceType) value;
+ final ReferenceType rValue = (ReferenceType) value;
referenceTypeIsInitialized(o, rValue);
// TODO: This can possibly only be checked using Staerk-et-al's "set-of-object types", not
// using "wider cast object types" created during verification.
@@ -1060,44 +1047,10 @@ public void visitGETFIELD(final GETFIELD o) {
final String fieldName = o.getFieldName(cpg);
final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName());
- Field[] fields = jc.getFields();
- Field f = null;
- for (final Field field : fields) {
- if (field.getName().equals(fieldName)) {
- final Type fType = Type.getType(field.getSignature());
- final Type oType = o.getType(cpg);
- /*
- * TODO: Check if assignment compatibility is sufficient. What does Sun do?
- */
- if (fType.equals(oType)) {
- f = field;
- break;
- }
- }
- }
-
- if (f == null) {
- final JavaClass[] superclasses = jc.getSuperClasses();
- outer: for (final JavaClass superclass : superclasses) {
- fields = superclass.getFields();
- for (final Field field : fields) {
- if (field.getName().equals(fieldName)) {
- final Type fType = Type.getType(field.getSignature());
- final Type oType = o.getType(cpg);
- if (fType.equals(oType)) {
- f = field;
- if ((f.getAccessFlags() & (Const.ACC_PUBLIC | Const.ACC_PROTECTED)) == 0) {
- f = null;
- }
- break outer;
- }
- }
- }
- }
+ final Field f = jc.findField(fieldName, o.getType(cpg));
if (f == null) {
throw new AssertionViolatedException("Field '" + fieldName + "' not found in " + jc.getClassName());
}
- }
if (f.isProtected()) {
final ObjectType classtype = getObjectType(o);
@@ -1627,12 +1580,12 @@ public void visitINVOKEINTERFACE(final INVOKEINTERFACE o) {
}
}
- final Type[] argtypes = o.getArgumentTypes(cpg);
- final int nargs = argtypes.length;
+ final Type[] argTypes = o.getArgumentTypes(cpg);
+ final int argCount = argTypes.length;
- for (int i = nargs - 1; i >= 0; i--) {
- final Type fromStack = stack().peek(nargs - 1 - i); // 0 to nargs-1
- Type fromDesc = argtypes[i];
+ for (int i = argCount - 1; i >= 0; i--) {
+ final Type fromStack = stack().peek(argCount - 1 - i); // 0 to argCount - 1
+ Type fromDesc = argTypes[i];
if (fromDesc == Type.BOOLEAN || fromDesc == Type.BYTE || fromDesc == Type.CHAR || fromDesc == Type.SHORT) {
fromDesc = Type.INT;
}
@@ -1653,33 +1606,33 @@ public void visitINVOKEINTERFACE(final INVOKEINTERFACE o) {
}
}
- Type objref = stack().peek(nargs);
- if (objref == Type.NULL) {
+ Type objRef = stack().peek(argCount);
+ if (objRef == Type.NULL) {
return;
}
- if (!(objref instanceof ReferenceType)) {
- constraintViolated(o, "Expecting a reference type as 'objectref' on the stack, not a '" + objref + "'.");
+ if (!(objRef instanceof ReferenceType)) {
+ constraintViolated(o, "Expecting a reference type as 'objectref' on the stack, not a '" + objRef + "'.");
}
- referenceTypeIsInitialized(o, (ReferenceType) objref);
- if (!(objref instanceof ObjectType)) {
- if (!(objref instanceof ArrayType)) { // could be a ReturnaddressType
- constraintViolated(o, "Expecting an ObjectType as 'objectref' on the stack, not a '" + objref + "'.");
+ referenceTypeIsInitialized(o, (ReferenceType) objRef);
+ if (!(objRef instanceof ObjectType)) {
+ if (!(objRef instanceof ArrayType)) { // could be a ReturnaddressType
+ constraintViolated(o, "Expecting an ObjectType as 'objectref' on the stack, not a '" + objRef + "'.");
} else {
- objref = GENERIC_ARRAY;
+ objRef = GENERIC_ARRAY;
}
}
- // String objref_classname = ((ObjectType) objref).getClassName();
+ // String objRefClassName = ((ObjectType) objRef).getClassName();
// String theInterface = o.getClassName(cpg);
// TODO: This can only be checked if we're using Staerk-et-al's "set of object types"
// instead of "wider cast object types" generated during verification.
- // if ( ! Repository.implementationOf(objref_classname, theInterface) ) {
- // constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theInterface+"' as expected.");
+ // if ( ! Repository.implementationOf(objRefClassName, theInterface) ) {
+ // constraintViolated(o, "The 'objRef' item '" + objRef + "' does not implement '" + theInterface + "' as expected.");
// }
int countedCount = 1; // 1 for the objectref
- for (int i = 0; i < nargs; i++) {
- countedCount += argtypes[i].getSize();
+ for (int i = 0; i < argCount; i++) {
+ countedCount += argTypes[i].getSize();
}
if (count != countedCount) {
constraintViolated(o, "The 'count' argument should probably read '" + countedCount + "' but is '" + count + "'.");
@@ -1824,7 +1777,7 @@ public void visitINVOKEVIRTUAL(final INVOKEVIRTUAL o) {
final String theClass = o.getClassName(cpg);
- if (!Repository.instanceOf(objRefClassName, theClass)) {
+ if (objref != GENERIC_ARRAY && !Repository.instanceOf(objRefClassName, theClass)) {
constraintViolated(o, "The 'objref' item '" + objref + "' does not implement '" + theClass + "' as expected.");
}
} catch (final ClassNotFoundException e) {
@@ -2084,9 +2037,14 @@ public void visitLDC(final LDC o) {
// visitCPInstruction is called first.
final Constant c = cpg.getConstant(o.getIndex());
- if (!(c instanceof ConstantInteger || c instanceof ConstantFloat || c instanceof ConstantString || c instanceof ConstantClass)) {
+ if (!(c instanceof ConstantInteger
+ || c instanceof ConstantFloat
+ || c instanceof ConstantString
+ || c instanceof ConstantClass
+ || c instanceof ConstantDynamic)) {
constraintViolated(o,
- "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float, a CONSTANT_String or a CONSTANT_Class, but is '" + c + "'.");
+ "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float, a CONSTANT_String, a CONSTANT_Class, or a CONSTANT_Dynamic but is '"
+ + c + "'.");
}
}
diff --git a/src/main/java/org/apache/bcel/verifier/structurals/InstructionContext.java b/src/main/java/org/apache/bcel/verifier/structurals/InstructionContext.java
index 0fa9aabc9c..7317424f23 100644
--- a/src/main/java/org/apache/bcel/verifier/structurals/InstructionContext.java
+++ b/src/main/java/org/apache/bcel/verifier/structurals/InstructionContext.java
@@ -73,7 +73,7 @@
InstructionContext[] getSuccessors();
/**
- * The getTag and setTag methods may be used for temporary flagging, such as graph colouring. Nothing in the
+ * The getTag and setTag methods may be used for temporary flagging, such as graph coloring. Nothing in the
* InstructionContext object depends on the value of the tag. JustIce does not use it.
*
* @see #setTag(int tag)
@@ -81,7 +81,7 @@
int getTag();
/**
- * The getTag and setTag methods may be used for temporary flagging, such as graph colouring. Nothing in the
+ * The getTag and setTag methods may be used for temporary flagging, such as graph coloring. Nothing in the
* InstructionContext object depends on the value of the tag. JustIce does not use it.
*
* @see #getTag()
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 4ce54076a4..5d928e9cef 100644
--- a/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java
+++ b/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java
@@ -68,7 +68,7 @@ private enum ColourConstants {
/**
* This inner class implements the Subroutine interface.
*/
- private @UsesObjectEquals class SubroutineImpl implements Subroutine {
+ private final @UsesObjectEquals class SubroutineImpl implements Subroutine {
/**
* UNSET, a symbol for an uninitialized localVariable field. This is used for the "top-level" Subroutine; i.e. no
* subroutine.
@@ -402,7 +402,7 @@ private static InstructionHandle[] getSuccessors(final InstructionHandle instruc
// CHECKSTYLE:ON
/**
- * Constructor.
+ * Constructs a new instance.
*
* @param mg A MethodGen object representing method to create the Subroutine objects of. Assumes that JustIce strict
* checks are needed.
@@ -412,7 +412,7 @@ public Subroutines(final MethodGen mg) {
}
/**
- * Constructor.
+ * Constructs a new instance.
*
* @param mg A MethodGen object representing method to create the Subroutine objects of.
* @param enableJustIceCheck whether to enable additional JustIce checks
diff --git a/src/main/java/org/apache/bcel/verifier/structurals/package-info.java b/src/main/java/org/apache/bcel/verifier/structurals/package-info.java
new file mode 100644
index 0000000000..ac133c2ebc
--- /dev/null
+++ b/src/main/java/org/apache/bcel/verifier/structurals/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+/**
+ * A PassVerifier class mostly used internally by JustIce, yielding a control flow graph for public use as a nice side effect.
+ * Package Specification
+ *
+ * This package contains a PassVerifier class for use with the JustIce verifier and its utility classes. Only the pass performing what Sun calls "Structural
+ * Constraints on Java Virtual Machine Code" has a PassVerifier class here. JustIce calls this pass "Pass 3b".
+ *
+ */
+package org.apache.bcel.verifier.structurals;
diff --git a/src/site/xdoc/download_bcel.xml b/src/site/xdoc/download_bcel.xml
index 9f49384f7b..4d6c7b02a2 100644
--- a/src/site/xdoc/download_bcel.xml
+++ b/src/site/xdoc/download_bcel.xml
@@ -113,32 +113,32 @@ limitations under the License.
-
+
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index fd17c29742..da5692d481 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -24,7 +24,6 @@
Commons Documentation Team
-
The Byte Code Engineering Library (Apache Commons BCEL™) is intended to give users a
@@ -34,7 +33,6 @@
of the given class: methods, fields and byte code instructions, in
particular.
-
Such objects can be read from an existing file, be transformed
by a program (e.g. a class loader at run-time) and written to a file again.
@@ -43,13 +41,11 @@
if you want to learn about the Java Virtual Machine (JVM) and the format of
Java .class files.
-
BCEL contains a byte code verifier named JustIce, which usually
gives you much better information about what's wrong with your
code than the standard JVM message.
-
BCEL is already being used successfully in several projects such
as compilers, optimizers, obsfuscators, code generators
@@ -58,7 +54,6 @@
might want to have a look into the ASM project at objectweb.
-
The package descriptions in the Javadoc give an overview of the available features
@@ -69,7 +64,6 @@
browsed, or you can browse/contribute via GitHub.
-
The latest stable release of BCEL is here, you may:
- Alternatively you can pull it from the central Maven repositories through a dependency.
+ Alternatively, you can pull it from the central Maven repositories through a dependency.
-
The commons developer mailing list is the main channel of communication for contributors. Please remember that the lists are shared between all commons components, so prefix your email by [bcel].
- You can also visit the #apache-commons IRC channel on irc.freenode.net or peruse JIRA.
+ You can also peruse JIRA.
Alternatively you can go through the Needs Work tags in the TagList report.
If you'd like to offer up pull requests via GitHub rather than applying patches to JIRA, we have a GitHub mirror.
diff --git a/src/site/xdoc/mail-lists.xml b/src/site/xdoc/mail-lists.xml
index 4d6a444258..ef05eac585 100644
--- a/src/site/xdoc/mail-lists.xml
+++ b/src/site/xdoc/mail-lists.xml
@@ -59,9 +59,9 @@ limitations under the License.
Questions related to the usage of Apache Commons BCEL should be posted to the
- User List.
+ User List.
- The Developer List
+ The Developer List
is for questions and discussion related to the development of Apache Commons BCEL.
Please do not cross-post; developers are also subscribed to the user list.
@@ -70,8 +70,10 @@ limitations under the License.
to subscribe.
- Note: please don't send patches or attachments to any of the mailing lists.
+ Note: please don't send patches or attachments to any of the mailing lists;
+ most of the lists are set up to drop attachments.
Patches are best handled via the Issue Tracking system.
+ If you have a GitHub account, most components also accept PRs (pull requests).
Otherwise, please upload the file to a public server and include the URL in the mail.
@@ -105,12 +107,11 @@ limitations under the License.
Subscribe |
Unsubscribe |
Post |
- mail-archives.apache.org
+ |
lists.apache.org
|
- markmail.org
- www.mail-archive.com
- news.gmane.org
+ |
+ www.mail-archive.com
|
@@ -125,12 +126,11 @@ limitations under the License.
Subscribe |
Unsubscribe |
Post |
- mail-archives.apache.org
+ |
lists.apache.org
|
- markmail.org
- www.mail-archive.com
- news.gmane.org
+ |
+ www.mail-archive.com
|
@@ -145,10 +145,10 @@ limitations under the License.
Subscribe |
Unsubscribe |
read only |
- mail-archives.apache.org
+ |
lists.apache.org
|
- markmail.org
+ |
www.mail-archive.com
|
@@ -164,10 +164,10 @@ limitations under the License.
Subscribe |
Unsubscribe |
read only |
- mail-archives.apache.org
+ |
lists.apache.org
|
- markmail.org
+ |
www.mail-archive.com
|
@@ -199,13 +199,11 @@ limitations under the License.
Subscribe |
Unsubscribe |
read only |
- mail-archives.apache.org
+ |
lists.apache.org
|
- markmail.org
- old.nabble.com
- www.mail-archive.com
- news.gmane.org
+ |
+ www.mail-archive.com
|
diff --git a/src/test/java/org/apache/bcel/AbstractTestCase.java b/src/test/java/org/apache/bcel/AbstractTestCase.java
index af1d5059d1..728dbbcef8 100644
--- a/src/test/java/org/apache/bcel/AbstractTestCase.java
+++ b/src/test/java/org/apache/bcel/AbstractTestCase.java
@@ -20,8 +20,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.List;
@@ -41,6 +39,7 @@
import org.apache.bcel.util.ClassPath;
import org.apache.bcel.util.SyntheticRepository;
import org.apache.bcel.verifier.VerifierFactory;
+import org.apache.commons.io.function.Uncheck;
public abstract class AbstractTestCase {
@@ -70,11 +69,11 @@ public AnnotationEntryGen createFruitAnnotationEntry(final ConstantPoolGen cp, f
}
public SyntheticRepository createRepos(final String cpentry) {
+ return Uncheck.get(() -> {
try (ClassPath cp = new ClassPath("target" + File.separator + "testdata" + File.separator + cpentry + File.separator)) {
return SyntheticRepository.getInstance(cp);
- } catch (final IOException e) {
- throw new UncheckedIOException(e);
}
+ });
}
/**
@@ -85,6 +84,38 @@ protected File createTestdataFile(final String name) {
return new File(TESTDATA, name);
}
+ /**
+ * Deletes a file under the TESTDATA directory
+ *
+ * @param name
+ * @return See {@link File#delete()}.
+ */
+ protected boolean delete(final String name) {
+ return new File(TESTDATA, name).delete();
+ }
+
+ /**
+ * Deletes a directory and file under the TESTDATA directory
+ *
+ * @param dir
+ * @param name
+ * @return true if the file was deleted
+ */
+ protected boolean delete(final String dir, final String name) {
+ // The parameter is relative to the TESTDATA dir
+ final boolean b = delete(dir + File.separator + name);
+ final File testDir = new File(TESTDATA, dir);
+ final String[] files = testDir.list();
+ if (files == null || files.length == 0) {
+ if (!testDir.delete()) {
+ System.err.println("Failed to remove: " + testDir);
+ }
+ } else {
+ System.err.println("Non-empty directory: " + testDir);
+ }
+ return b;
+ }
+
protected String dumpAnnotationEntries(final AnnotationEntry[] as) {
final StringBuilder result = new StringBuilder();
result.append("[");
@@ -163,36 +194,4 @@ protected JavaClass getTestJavaClass(final String name) throws ClassNotFoundExce
return SyntheticRepository.getInstance().loadClass(name);
}
- /**
- * Delete a file under the TESTDATA directory
- *
- * @param name
- * @return
- */
- protected boolean wipe(final String name) {
- return new File(TESTDATA, name).delete();
- }
-
- /**
- * Delete a directory and file under the TESTDATA directory
- *
- * @param dir
- * @param name
- * @return true if the file was deleted
- */
- protected boolean wipe(final String dir, final String name) {
- // The parameter is relative to the TESTDATA dir
- final boolean b = wipe(dir + File.separator + name);
- final File testDir = new File(TESTDATA, dir);
- final String[] files = testDir.list();
- if (files == null || files.length == 0) {
- if (!testDir.delete()) {
- System.err.println("Failed to remove: " + testDir);
- }
- } else {
- System.err.println("Non-empty directory: " + testDir);
- }
- return b;
- }
-
}
diff --git a/src/test/java/org/apache/bcel/AnnotationEntryTest.java b/src/test/java/org/apache/bcel/AnnotationEntryTest.java
new file mode 100644
index 0000000000..772385835e
--- /dev/null
+++ b/src/test/java/org/apache/bcel/AnnotationEntryTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.bcel.classfile.AnnotationEntry;
+import org.apache.bcel.classfile.ElementValuePair;
+import org.apache.bcel.classfile.SimpleElementValue;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link AnnotationEntry}.
+ */
+public class AnnotationEntryTest {
+
+ @Test
+ public void testAddElementNameValuePair() {
+ final AnnotationEntry annotationEntry = new AnnotationEntry(0, null, false);
+ annotationEntry.addElementNameValuePair(new ElementValuePair(0, new SimpleElementValue(0, 0, null), null));
+ assertEquals(1, annotationEntry.getNumElementValuePairs());
+ }
+
+ @Test
+ public void testDump() throws IOException {
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ new AnnotationEntry(0, null, false).dump(new DataOutputStream(out));
+ assertArrayEquals(new byte[4], out.toByteArray());
+ }
+
+ @Test
+ public void testGetElementValuePairs() {
+ assertEquals(0, new AnnotationEntry(0, null, false).getElementValuePairs().length);
+ }
+
+ @Test
+ public void testGetNumElementValuePairs() {
+ assertEquals(0, new AnnotationEntry(0, null, false).getNumElementValuePairs());
+ }
+}
diff --git a/src/test/java/org/apache/bcel/BCELBenchmark.java b/src/test/java/org/apache/bcel/BCELBenchmark.java
index 9396ec829a..2b62a1ea8f 100644
--- a/src/test/java/org/apache/bcel/BCELBenchmark.java
+++ b/src/test/java/org/apache/bcel/BCELBenchmark.java
@@ -29,7 +29,6 @@
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.MethodGen;
-import org.apache.commons.collections4.Predicate;
import org.apache.commons.collections4.iterators.EnumerationIterator;
import org.apache.commons.collections4.iterators.FilterIterator;
import org.apache.commons.collections4.iterators.IteratorIterable;
@@ -38,7 +37,6 @@
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
-import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
@@ -52,20 +50,6 @@
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class BCELBenchmark {
- private JarFile getJarFile() throws IOException {
- final String javaHome = System.getProperty("java.home");
- return new JarFile(javaHome + "/lib/rt.jar");
- }
-
- private Iterable getClasses(JarFile jar) {
- return new IteratorIterable<>(new FilterIterator<>(new EnumerationIterator<>(jar.entries()), new Predicate() {
- @Override
- public boolean evaluate(JarEntry entry) {
- return entry.getName().endsWith(JavaClass.EXTENSION);
- }
- }));
- }
-
/**
* Baseline benchmark. Read the classes but don't parse them.
*/
@@ -81,20 +65,6 @@ public void baseline(Blackhole bh) throws IOException {
jar.close();
}
- @Benchmark
- public void parser(Blackhole bh) throws IOException {
- JarFile jar = getJarFile();
-
- for (JarEntry entry : getClasses(jar)) {
- byte[] bytes = IOUtils.toByteArray(jar.getInputStream(entry));
-
- JavaClass clazz = new ClassParser(new ByteArrayInputStream(bytes), entry.getName()).parse();
- bh.consume(clazz);
- }
-
- jar.close();
- }
-
@Benchmark
public void generator(Blackhole bh) throws IOException {
JarFile jar = getJarFile();
@@ -123,4 +93,32 @@ public void generator(Blackhole bh) throws IOException {
jar.close();
}
+
+ private Iterable getClasses(JarFile jar) {
+ return new IteratorIterable<>(new FilterIterator<>(new EnumerationIterator<>(jar.entries()), new Predicate() {
+ @Override
+ public boolean evaluate(JarEntry entry) {
+ return entry.getName().endsWith(JavaClass.EXTENSION);
+ }
+ }));
+ }
+
+ private JarFile getJarFile() throws IOException {
+ final String javaHome = System.getProperty("java.home");
+ return new JarFile(javaHome + "/lib/rt.jar");
+ }
+
+ @Benchmark
+ public void parser(Blackhole bh) throws IOException {
+ JarFile jar = getJarFile();
+
+ for (JarEntry entry : getClasses(jar)) {
+ byte[] bytes = IOUtils.toByteArray(jar.getInputStream(entry));
+
+ JavaClass clazz = new ClassParser(new ByteArrayInputStream(bytes), entry.getName()).parse();
+ bh.consume(clazz);
+ }
+
+ jar.close();
+ }
}
diff --git a/src/test/java/org/apache/bcel/CounterVisitorTestCase.java b/src/test/java/org/apache/bcel/CounterVisitorTestCase.java
index 0cdc69f1c4..d1fcfa5e35 100644
--- a/src/test/java/org/apache/bcel/CounterVisitorTestCase.java
+++ b/src/test/java/org/apache/bcel/CounterVisitorTestCase.java
@@ -203,6 +203,11 @@ public void testStackMapEntryCount() {
assertEquals(0, getVisitor().stackMapEntryCount, "stackMapEntryCount");
}
+ @Test
+ public void testStackMapTypeCount() {
+ assertEquals(0, getVisitor().stackMapTypeCount, "stackMapTypeCount");
+ }
+
@Test
public void testSyntheticCount() {
assertEquals(0, getVisitor().syntheticCount, "syntheticCount");
diff --git a/src/test/java/org/apache/bcel/EnclosingMethodAttributeTestCase.java b/src/test/java/org/apache/bcel/EnclosingMethodAttributeTestCase.java
index 18e1f23949..b94a4a4c0a 100644
--- a/src/test/java/org/apache/bcel/EnclosingMethodAttributeTestCase.java
+++ b/src/test/java/org/apache/bcel/EnclosingMethodAttributeTestCase.java
@@ -31,6 +31,7 @@
import org.junit.jupiter.api.Test;
public class EnclosingMethodAttributeTestCase extends AbstractTestCase {
+
/**
* Check that we can save and load the attribute correctly.
*/
diff --git a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java
index a03b134917..6d5068efc1 100644
--- a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java
+++ b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java
@@ -135,12 +135,12 @@ public void testWithGenericArguement() throws ClassNotFoundException, NoSuchMeth
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.invoke(null, "a1", new LinkedList<>());
method = cls.getDeclaredMethod("b", String.class, List.class);
- method.invoke(null, "b1", new LinkedList());
+ 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");
+ method.invoke(null, new LinkedList<>(), "d2");
}
}
diff --git a/src/test/java/org/apache/bcel/OssFuzzTestCase.java b/src/test/java/org/apache/bcel/OssFuzzTestCase.java
index ed0129891e..d685a32267 100644
--- a/src/test/java/org/apache/bcel/OssFuzzTestCase.java
+++ b/src/test/java/org/apache/bcel/OssFuzzTestCase.java
@@ -47,9 +47,8 @@ public void testIssue53543() throws Exception {
testOssFuzzReproducer("53543");
}
- /*
- * The original issue 53544 was a false positive but reviewing that issue
- * did find a valid issue nearby.
+ /**
+ * The original issue 53544 was a false positive but reviewing that issue did find a valid issue nearby.
*/
@Test
public void testIssue53544a() throws Exception {
@@ -61,8 +60,24 @@ public void testIssue53620() throws Exception {
testOssFuzzReproducer("53620");
}
+ @Test
+ public void testIssue53676() throws Exception {
+ testOssFuzzReproducer("53676");
+ }
+
+ @Test
+ public void testIssue54119() throws Exception {
+ testOssFuzzReproducer("54119");
+ }
+
+ @Test
+ public void testIssue54254() throws Exception {
+ testOssFuzzReproducer("54254");
+ }
+
private void testOssFuzzReproducer(final String issue) throws Exception {
- final File reproducerFile = new File("target/test-classes/ossfuzz/issue" + issue + "/Test.class");
+ // Class names here use non-".class" suffix so that Maven plugins like surefire do not try to read the file and fail the build.
+ final File reproducerFile = new File("target/test-classes/ossfuzz/issue" + issue + "/Test.classx");
try (final FileInputStream reproducerInputStream = new FileInputStream(reproducerFile)) {
final ClassParser cp = new ClassParser(reproducerInputStream, "Test");
assertThrows(ClassFormatException.class, () -> cp.parse());
diff --git a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleToStringTestCase.java b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleToStringTestCase.java
index 89976d43d2..2d22c52c3f 100644
--- a/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleToStringTestCase.java
+++ b/src/test/java/org/apache/bcel/classfile/ConstantPoolModuleToStringTestCase.java
@@ -385,7 +385,17 @@ public void visitModuleRequires(final ModuleRequires constantModule) {
append(constantModule);
append(constantModule.toString(pool));
final String s = constantModule.toString(pool).trim();
- assertTrue(StringUtils.startsWithAny(s, "jdk.", "java.", "org.junit", "org.apiguardian.api", "org.opentest4j"), s);
+ final boolean condition = StringUtils.startsWithAny(s,
+ "jdk.",
+ "java.",
+ "org.junit",
+ "org.apiguardian.api",
+ "org.opentest4j",
+ "net.bytebuddy",
+ "com.sun.jna",
+ "junit",
+ "org.hamcrest");
+ assertTrue(condition, s);
}
@Override
diff --git a/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java b/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java
index a18b3993a2..cc246e823a 100644
--- a/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java
+++ b/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java
@@ -17,13 +17,12 @@
package org.apache.bcel.classfile;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
-import java.util.stream.IntStream;
import org.apache.bcel.AbstractTestCase;
import org.apache.bcel.Const;
@@ -34,11 +33,11 @@
import org.apache.bcel.util.ClassPathRepository;
import org.junit.jupiter.api.Test;
-class ClassWithDoubleConstantPoolItem {
+final class ClassWithDoubleConstantPoolItem {
double d = 42; // here is the key; we need a double constant value
}
-class ClassWithLongConstantPoolItem {
+final class ClassWithLongConstantPoolItem {
long l = 42; // here is the key; we need a double constant value
}
@@ -59,13 +58,19 @@ public void testClassWithDoubleConstantPoolItem() throws ClassNotFoundException,
assertEquals(1, fields.length);
assertEquals(ClassWithDoubleConstantPoolItem.class.getDeclaredFields()[0].getName(), fields[0].getName());
final ConstantPool pool = c.getConstantPool();
- IntStream.range(0, pool.getLength()).forEach(i -> assertDoesNotThrow(() -> {
+ for (int i = 1; i < pool.getLength(); i++) {
+ try {
final Constant constant = pool.getConstant(i);
if (constant instanceof ConstantDouble) {
assertEquals(classWithDoubleConstantPoolItem.d, ((ConstantDouble) constant).getBytes());
+ // Next constant pool entry will be invalid so skip it
+ i++;
+ }
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ fail();
+ }
}
- return constant;
- }));
}
}
@@ -79,13 +84,19 @@ public void testClassWithLongConstantPoolItem() throws ClassNotFoundException, I
assertEquals(1, fields.length);
assertEquals(ClassWithLongConstantPoolItem.class.getDeclaredFields()[0].getName(), fields[0].getName());
final ConstantPool pool = c.getConstantPool();
- IntStream.range(0, pool.getLength()).forEach(i -> assertDoesNotThrow(() -> {
+ for (int i = 1; i < pool.getLength(); i++) {
+ try {
final Constant constant = pool.getConstant(i);
if (constant instanceof ConstantLong) {
assertEquals(classWithLongConstantPoolItem.l, ((ConstantLong) constant).getBytes());
+ // Next constant pool entry will be invalid so skip it
+ i++;
+ }
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ fail();
+ }
}
- return constant;
- }));
}
}
diff --git a/src/test/java/org/apache/bcel/classfile/ConstantTest.java b/src/test/java/org/apache/bcel/classfile/ConstantTest.java
new file mode 100644
index 0000000000..3769b58bbd
--- /dev/null
+++ b/src/test/java/org/apache/bcel/classfile/ConstantTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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 static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link Constant}.
+ */
+public class ConstantTest {
+
+ @Test
+ public void testBCELComparator() throws Exception {
+ final Constant obj = new ConstantClass(1);
+ assertTrue(Constant.getComparator().equals(null, null));
+ assertTrue(Constant.getComparator().equals(obj, obj));
+ assertFalse(Constant.getComparator().equals(obj, null));
+ assertFalse(Constant.getComparator().equals(null, obj));
+ }
+}
diff --git a/src/test/java/org/apache/bcel/classfile/FieldTest.java b/src/test/java/org/apache/bcel/classfile/FieldTest.java
new file mode 100644
index 0000000000..3b41293f2b
--- /dev/null
+++ b/src/test/java/org/apache/bcel/classfile/FieldTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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 static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link Field}.
+ */
+public class FieldTest {
+
+ @Test
+ public void testBCELComparator() throws Exception {
+ final Field obj = new Field(1, 1, 1, null, null);
+ assertTrue(Field.getComparator().equals(null, null));
+ assertTrue(Field.getComparator().equals(obj, obj));
+ assertFalse(Field.getComparator().equals(obj, null));
+ assertFalse(Field.getComparator().equals(null, obj));
+ }
+}
diff --git a/src/test/java/org/apache/bcel/classfile/InvalidMethodSigantureTestCase.java b/src/test/java/org/apache/bcel/classfile/InvalidMethodSigantureTestCase.java
new file mode 100644
index 0000000000..6547fc2718
--- /dev/null
+++ b/src/test/java/org/apache/bcel/classfile/InvalidMethodSigantureTestCase.java
@@ -0,0 +1,83 @@
+/*
+ * 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 static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * javap input:
+ *
+ *
+ * javap "src/test/resources/kotlin/test$method name with () in it$1.class"
+ *
+ *
+ * javap output:
+ *
+ *
+ *
+Compiled from "test.kt"
+final class test$method name with () in it$1 extends kotlin.jvm.internal.Lambda implements kotlin.jvm.functions.Function0 {
+ public static final test$method name with () in it$1 INSTANCE;
+ test$method name with () in it$1();
+ public final void invoke();
+ public java.lang.Object invoke();
+ static {};
+ *
+ */
+public class InvalidMethodSigantureTestCase {
+
+ final class TestVisitor extends org.apache.bcel.classfile.EmptyVisitor {
+ @Override
+ public void visitField(final Field field) {
+ field.getType();
+ }
+ }
+ private static final String CLASS_NAME = "test$method name with () in it$1";
+
+ private static final String SRC_TEST_RESOURCES_KOTLIN = "src/test/resources/kotlin/";
+
+ @Test
+ public void testLoadClass() throws Exception {
+ final Path path = Paths.get(SRC_TEST_RESOURCES_KOTLIN);
+ assertTrue(Files.exists(path));
+ assertTrue(Files.isDirectory(path));
+ try (URLClassLoader cl = URLClassLoader.newInstance(new URL[] { path.toUri().toURL() })) {
+ Class.forName(CLASS_NAME, false, cl);
+ }
+ }
+
+ @Test
+ //@Disabled("TODO?")
+ public void testMethodWithParens() throws Exception {
+ try (final InputStream inputStream = Files.newInputStream(Paths.get(SRC_TEST_RESOURCES_KOTLIN, CLASS_NAME + ".class"))) {
+ final ClassParser classParser = new ClassParser(inputStream, CLASS_NAME);
+ final JavaClass javaClass = classParser.parse();
+ final TestVisitor visitor = new TestVisitor();
+ new DescendingVisitor(javaClass, visitor).visit();
+ }
+ }
+}
diff --git a/src/test/java/org/apache/bcel/classfile/JDKClassDumpTestCase.java b/src/test/java/org/apache/bcel/classfile/JDKClassDumpTestCase.java
index 36264fbe7d..d1d36473ed 100644
--- a/src/test/java/org/apache/bcel/classfile/JDKClassDumpTestCase.java
+++ b/src/test/java/org/apache/bcel/classfile/JDKClassDumpTestCase.java
@@ -65,7 +65,8 @@ private void testJar(final Path path) throws Exception {
final String name = e.getName();
if (name.endsWith(JavaClass.EXTENSION)) {
// System.out.println("Parsing " + name);
- try (InputStream inputStream1 = jar.getInputStream(e); InputStream inputStream2 = jar.getInputStream(e);) {
+ try (InputStream inputStream1 = jar.getInputStream(e);
+ InputStream inputStream2 = jar.getInputStream(e);) {
compare(new ClassParser(inputStream1, name).parse(), inputStream2, name);
}
}
diff --git a/src/test/java/org/apache/bcel/classfile/SignatureTestCase.java b/src/test/java/org/apache/bcel/classfile/SignatureTestCase.java
new file mode 100644
index 0000000000..eb3d5e4fcc
--- /dev/null
+++ b/src/test/java/org/apache/bcel/classfile/SignatureTestCase.java
@@ -0,0 +1,83 @@
+/*
+ * 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 static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
+
+import java.io.DataInput;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.bcel.AbstractTestCase;
+import org.apache.bcel.Repository;
+import org.apache.bcel.generic.Type;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests signatures, including primitives, generics, and bad signatures for exceptions.
+ */
+public class SignatureTestCase extends AbstractTestCase {
+
+ @Test
+ public void testBadSignatures() throws Exception {
+ assertThrowsExactly(IllegalArgumentException.class, () -> Signature.translate("<"));
+ assertThrowsExactly(IllegalArgumentException.class, () -> Signature.translate("<>"));
+ }
+
+ @Test
+ public void testMap() throws Exception {
+ final JavaClass jc = Repository.lookupClass(Map.class);
+ final Signature classSignature = (Signature) findAttribute("Signature", jc.getAttributes());
+ final String translatedSignature = Signature.translate(classSignature.getSignature());
+ assertEquals("java.lang.Object", translatedSignature);
+ testMethod(jc, "(java.lang.Object)V", Map.class, "get", Object.class);
+ testMethod(jc, "(K, V)V", Map.class, "put", Object.class, Object.class);
+ }
+
+ void testMethod(final JavaClass jc, final String expected, final Class> clazz, final String methodName, final Class>... paramTypes) throws Exception {
+ final Method method = jc.getMethod(clazz.getMethod(methodName, paramTypes));
+ final String methodSignature = Optional.ofNullable(method.getGenericSignature()).orElse(method.getSignature());
+ final String translatedMethodSignature = Signature.translate(methodSignature);
+ assertEquals(expected, translatedMethodSignature);
+ }
+
+ @Test
+ public void testString() throws Exception {
+ final JavaClass jc = Repository.lookupClass(String.class);
+ final Signature classSignature = (Signature) findAttribute("Signature", jc.getAttributes());
+ final String translatedSignature = Signature.translate(classSignature.getSignature());
+ assertEquals("java.lang.Object", translatedSignature);
+ testMethod(jc, "()java.lang.String", String.class, "trim");
+
+ }
+
+ @Test
+ public void testType() throws Exception {
+ assertEquals("(I)I", Type.getSignature(Math.class.getMethod("abs", int.class)));
+ assertEquals("(J)J", Type.getSignature(Math.class.getMethod("abs", long.class)));
+ assertEquals("(D)D", Type.getSignature(Math.class.getMethod("abs", double.class)));
+ assertEquals("(F)F", Type.getSignature(Math.class.getMethod("abs", float.class)));
+ assertEquals("(Ljava/lang/String;)[Ljava/lang/String;", Type.getSignature(String.class.getMethod("split", String.class)));
+ assertEquals("(I)C", Type.getSignature(String.class.getMethod("charAt", int.class)));
+ assertEquals("()Ljava/lang/String;", Type.getSignature(String.class.getMethod("trim")));
+ assertEquals("()V", Type.getSignature(Object.class.getMethod("notify")));
+ assertEquals("(Ljava/lang/Object;)Z", Type.getSignature(Object.class.getMethod("equals", Object.class)));
+ assertEquals("()B", Type.getSignature(DataInput.class.getMethod("readByte")));
+ assertEquals("()S", Type.getSignature(DataInput.class.getMethod("readShort")));
+ }
+}
diff --git a/src/test/java/org/apache/bcel/classfile/StackMapTest.java b/src/test/java/org/apache/bcel/classfile/StackMapTest.java
new file mode 100644
index 0000000000..bfef4e2e70
--- /dev/null
+++ b/src/test/java/org/apache/bcel/classfile/StackMapTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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 static org.junit.jupiter.api.Assertions.assertArrayEquals;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link StackMap}.
+ */
+public class StackMapTest {
+
+ @Test
+ public void testSetStackMap() {
+ final StackMap stackMap = new StackMap(0, 0, StackMapEntry.EMPTY_ARRAY, new ConstantPool(new Constant[] { new ConstantLong(0) }));
+ // No NPE
+ stackMap.setStackMap(null);
+ assertArrayEquals(StackMapEntry.EMPTY_ARRAY, stackMap.getStackMap());
+ }
+}
diff --git a/src/test/java/org/apache/bcel/classfile/TestJira368.java b/src/test/java/org/apache/bcel/classfile/TestJira368.java
new file mode 100644
index 0000000000..427276b913
--- /dev/null
+++ b/src/test/java/org/apache/bcel/classfile/TestJira368.java
@@ -0,0 +1,65 @@
+/*
+ * 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 static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.io.IOException;
+
+import org.apache.bcel.generic.InstructionList;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests BCEL-368.
+ */
+public class TestJira368 {
+
+ private JavaClass parseJavaClass() throws IOException {
+ return new ClassParser("src/test/resources/jira368/Test.class").parse();
+ }
+
+ @Test
+ public void testInstructionListStringBrief() throws Exception {
+ for (final Method method : parseJavaClass().getMethods()) {
+ if (!method.isAbstract() && !method.isNative()) {
+ final InstructionList instructionList = new InstructionList(method.getCode().getCode());
+ final String string = instructionList.toString(false);
+ assertNotNull(string);
+ }
+ }
+ }
+
+ @Test
+ public void testInstructionListStringVerbose() throws Exception {
+ for (final Method method : parseJavaClass().getMethods()) {
+ if (!method.isAbstract() && !method.isNative()) {
+ final InstructionList instructionList = new InstructionList(method.getCode().getCode());
+ final String string = instructionList.toString(true);
+ assertNotNull(string);
+ }
+ }
+ }
+
+ @Test
+ public void testMethodSignature() throws Exception {
+ final String string = parseJavaClass().toString();
+ // System.out.println(string);
+ assertNotNull(string);
+ }
+
+}
diff --git a/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java b/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java
index 0829e7495f..8c3144b66e 100644
--- a/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java
+++ b/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java
@@ -22,10 +22,11 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.util.Arrays;
+
import org.apache.bcel.Const;
import org.apache.bcel.Repository;
import org.junit.jupiter.api.Test;
-import java.util.Arrays;
public class UtilityTestCase {
@@ -40,6 +41,46 @@ public void testClearBit() {
assertEquals(0, Utility.clearBit(Integer.MIN_VALUE, 31), "100...00 set bit 31 to 0 -> 000..00");
}
+ @Test
+ public void testCodeToString() throws Exception {
+ final class CodeToString {
+ int[][] a = new int[0][0];
+
+ CodeToString() {
+ if (a instanceof int[][]) {
+ System.out.print(Arrays.asList(a).size());
+ }
+ }
+ }
+ final JavaClass javaClass = Repository.lookupClass(CodeToString.class);
+ assertNotNull(javaClass);
+ for (final Method method : javaClass.getMethods()) {
+ assertEquals("", method.getName());
+ final String code = method.getCode().toString(false);
+ assertTrue(code.contains("0: aload_0"), code);
+ assertTrue(code.contains("1: aload_1"), code);
+ assertTrue(code.contains("2: putfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.this$0 Lorg/apache/bcel/classfile/UtilityTestCase;"), code);
+ assertTrue(code.contains("5: aload_0"), code);
+ assertTrue(code.contains("6: invokespecial\tjava.lang.Object. ()V"), code);
+ assertTrue(code.contains("9: aload_0"), code);
+ assertTrue(code.contains("10: iconst_0"), code);
+ assertTrue(code.contains("11: iconst_0"), code);
+ assertTrue(code.contains("12: multianewarray\t<[[I>\t2"), code);
+ assertTrue(code.contains("16: putfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.a [[I"), code);
+ assertTrue(code.contains("19: aload_0"), code);
+ assertTrue(code.contains("20: getfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.a [[I"), code);
+ assertTrue(code.contains("23: instanceof\t<[[I>"), code);
+ assertTrue(code.contains("26: ifeq\t\t#47"), code);
+ assertTrue(code.contains("29: getstatic\t\tjava.lang.System.out Ljava/io/PrintStream;"), code);
+ assertTrue(code.contains("32: aload_0"), code);
+ 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("47: return"), code);
+ }
+ }
+
@Test
public void testConvertString() {
assertEquals("\\n", Utility.convertString("\n"));
@@ -131,44 +172,4 @@ public void testSignatureToStringWithGenerics() throws Exception {
assertEquals(" extends Object",
Utility.signatureToString("Ljava/lang/Object;"), "class signature");
}
-
- @Test
- public void testCodeToString() throws Exception {
- class CodeToString {
- int[][] a = new int[0][0];
-
- CodeToString() {
- if (a instanceof int[][]) {
- System.out.print(Arrays.asList(a).size());
- }
- }
- }
- final JavaClass javaClass = Repository.lookupClass(CodeToString.class);
- assertNotNull(javaClass);
- for (final Method method : javaClass.getMethods()) {
- assertEquals("", method.getName());
- final String code = method.getCode().toString(false);
- assertTrue(code.contains("0: aload_0"), code);
- assertTrue(code.contains("1: aload_1"), code);
- assertTrue(code.contains("2: putfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.this$0 Lorg/apache/bcel/classfile/UtilityTestCase;"), code);
- assertTrue(code.contains("5: aload_0"), code);
- assertTrue(code.contains("6: invokespecial\tjava.lang.Object. ()V"), code);
- assertTrue(code.contains("9: aload_0"), code);
- assertTrue(code.contains("10: iconst_0"), code);
- assertTrue(code.contains("11: iconst_0"), code);
- assertTrue(code.contains("12: multianewarray\t<[[I>\t2"), code);
- assertTrue(code.contains("16: putfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.a [[I"), code);
- assertTrue(code.contains("19: aload_0"), code);
- assertTrue(code.contains("20: getfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.a [[I"), code);
- assertTrue(code.contains("23: instanceof\t<[[I>"), code);
- assertTrue(code.contains("26: ifeq\t\t#47"), code);
- assertTrue(code.contains("29: getstatic\t\tjava.lang.System.out Ljava/io/PrintStream;"), code);
- assertTrue(code.contains("32: aload_0"), code);
- 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("47: return"), code);
- }
- }
}
diff --git a/src/test/java/org/apache/bcel/data/AnonymousClassTest.java b/src/test/java/org/apache/bcel/data/AnonymousClassTest.java
index 7ae31a6d30..89b3119277 100644
--- a/src/test/java/org/apache/bcel/data/AnonymousClassTest.java
+++ b/src/test/java/org/apache/bcel/data/AnonymousClassTest.java
@@ -18,7 +18,7 @@
package org.apache.bcel.data;
public class AnonymousClassTest {
- class X {
+ final class X {
}
static class Y {
diff --git a/src/test/java/org/apache/bcel/data/AttributeTestClassEM01.java b/src/test/java/org/apache/bcel/data/AttributeTestClassEM01.java
index ff9f0ad712..dbbe1fb456 100644
--- a/src/test/java/org/apache/bcel/data/AttributeTestClassEM01.java
+++ b/src/test/java/org/apache/bcel/data/AttributeTestClassEM01.java
@@ -20,7 +20,7 @@
public class AttributeTestClassEM01 {
public static void main(final String[] argv) {
@SuppressWarnings("unused")
- class S {
+ final class S {
public void sayhello() {
System.err.println("hello");
}
diff --git a/src/test/java/org/apache/bcel/data/LargeMethod.java b/src/test/java/org/apache/bcel/data/LargeMethod.java
index a9c009e7b1..fd0e829db2 100644
--- a/src/test/java/org/apache/bcel/data/LargeMethod.java
+++ b/src/test/java/org/apache/bcel/data/LargeMethod.java
@@ -20,7 +20,7 @@
// Due to the way try finally is implemented in the standard java compiler
// from Oracle, this class generates a huge (>32767 code bytes) method.
// Verified with javac versions 1.8.0_261, 11.0.10 and 17.0.1.
-class LargeMethod {
+final class LargeMethod {
{
@SuppressWarnings("unused")
int a;
diff --git a/src/test/java/org/apache/bcel/data/SWAP.java b/src/test/java/org/apache/bcel/data/SWAP.java
new file mode 100644
index 0000000000..81a291e24b
--- /dev/null
+++ b/src/test/java/org/apache/bcel/data/SWAP.java
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+import java.lang.reflect.Constructor;
+
+/*
+ * A test for SWAP instruction.
+ * To be compiled with Eclipse Compiler (ecj) with source/target 1.4.
+ * This is a requirement for SWAP instruction to be generated.
+ * If compiled with javac source/target 1.1+ or ecj source/target 1.5+, no SWAP instruction is generated.
+ */
+public class SWAP {
+ public static Constructor getTestConstructor(final Class theClass) throws NoSuchMethodException {
+ final Class[] args = { String.class };
+ try {
+ return theClass.getConstructor(args);
+ } catch (final NoSuchMethodException e) {
+ }
+ return theClass.getConstructor(new Class[0]);
+ }
+}
diff --git a/src/test/java/org/apache/bcel/generic/BREAKPOINTTestCase.java b/src/test/java/org/apache/bcel/generic/BREAKPOINTTestCase.java
index 6b4d2a4f47..c62f6d18bc 100644
--- a/src/test/java/org/apache/bcel/generic/BREAKPOINTTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/BREAKPOINTTestCase.java
@@ -22,7 +22,7 @@
public class BREAKPOINTTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final BREAKPOINT breakpoint = new BREAKPOINT();
breakpoint.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/BinaryOpCreator.java b/src/test/java/org/apache/bcel/generic/BinaryOpCreator.java
index 3d372b8f1b..9a96851c37 100644
--- a/src/test/java/org/apache/bcel/generic/BinaryOpCreator.java
+++ b/src/test/java/org/apache/bcel/generic/BinaryOpCreator.java
@@ -16,18 +16,18 @@
*/
package org.apache.bcel.generic;
-import org.apache.bcel.Const;
-import org.apache.bcel.classfile.StackMap;
-import org.apache.bcel.classfile.StackMapEntry;
-import org.apache.bcel.classfile.StackMapType;
-import org.apache.commons.lang.ArrayUtils;
-
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import org.apache.bcel.Const;
+import org.apache.bcel.classfile.StackMap;
+import org.apache.bcel.classfile.StackMapEntry;
+import org.apache.bcel.classfile.StackMapType;
+import org.apache.commons.lang.ArrayUtils;
+
public class BinaryOpCreator {
private static final String ORG_APACHE_BCEL_GENERIC_BINARY_OP = "org.apache.bcel.generic.BinaryOp";
@@ -115,11 +115,13 @@ private void createMethodCalculate() {
"calculate", ORG_APACHE_BCEL_GENERIC_BINARY_OP, il, cp);
method.addException("java.lang.Exception");
final StackMapType[] typesOfLocals = { new StackMapType((byte) 7, cp.addClass("java.lang.String"), cp.getConstantPool()) };
- final StackMapEntry[] table = { new StackMapEntry(252, 70, typesOfLocals, StackMapType.EMPTY_ARRAY, cp.getConstantPool()),
- new StackMapEntry(251, 65, StackMapType.EMPTY_ARRAY, StackMapType.EMPTY_ARRAY, cp.getConstantPool()),
- new StackMapEntry(251, 65, StackMapType.EMPTY_ARRAY, StackMapType.EMPTY_ARRAY, cp.getConstantPool()),
- new StackMapEntry(251, 65, StackMapType.EMPTY_ARRAY, StackMapType.EMPTY_ARRAY, cp.getConstantPool()) };
- method.addCodeAttribute(new StackMap(cp.addUtf8("StackMapTable"), 17, table, cp.getConstantPool()));
+ final StackMapEntry[] table = { new StackMapEntry(252, 70, typesOfLocals, null, cp.getConstantPool()),
+ new StackMapEntry(251, 65, null, null, cp.getConstantPool()),
+ new StackMapEntry(251, 65, null, null, cp.getConstantPool()),
+ new StackMapEntry(251, 65, null, null, cp.getConstantPool()) };
+ final StackMap stackMap = new StackMap(cp.addUtf8("StackMapTable"), 17, table, cp.getConstantPool());
+ stackMap.setStackMap(table);
+ method.addCodeAttribute(stackMap);
il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
il.append(new PUSH(cp, 0));
diff --git a/src/test/java/org/apache/bcel/generic/ClassGenTest.java b/src/test/java/org/apache/bcel/generic/ClassGenTest.java
new file mode 100644
index 0000000000..742805b29e
--- /dev/null
+++ b/src/test/java/org/apache/bcel/generic/ClassGenTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.generic;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link ClassGen}.
+ */
+public class ClassGenTest {
+
+ @Test
+ public void testBCELComparator() throws Exception {
+ final ClassGen obj = new ClassGen("", "", "", 0, null);
+ assertTrue(ClassGen.getComparator().equals(null, null));
+ assertTrue(ClassGen.getComparator().equals(obj, obj));
+ assertFalse(ClassGen.getComparator().equals(obj, null));
+ assertFalse(ClassGen.getComparator().equals(null, obj));
+ }
+}
diff --git a/src/test/java/org/apache/bcel/generic/D2FTestCase.java b/src/test/java/org/apache/bcel/generic/D2FTestCase.java
index eb80b245ce..78a8c09cf5 100644
--- a/src/test/java/org/apache/bcel/generic/D2FTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/D2FTestCase.java
@@ -22,7 +22,7 @@
public class D2FTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final D2F d2f = new D2F();
d2f.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/D2ITestCase.java b/src/test/java/org/apache/bcel/generic/D2ITestCase.java
index bba89697ad..a297ecc921 100644
--- a/src/test/java/org/apache/bcel/generic/D2ITestCase.java
+++ b/src/test/java/org/apache/bcel/generic/D2ITestCase.java
@@ -22,7 +22,7 @@
public class D2ITestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final D2I d2i = new D2I();
d2i.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/D2LTestCase.java b/src/test/java/org/apache/bcel/generic/D2LTestCase.java
index e8ba042a2e..5cecd8329d 100644
--- a/src/test/java/org/apache/bcel/generic/D2LTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/D2LTestCase.java
@@ -22,7 +22,7 @@
public class D2LTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final D2L d2l = new D2L();
d2l.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/DADDTestCase.java b/src/test/java/org/apache/bcel/generic/DADDTestCase.java
index 2f0bdee825..86b95afc7b 100644
--- a/src/test/java/org/apache/bcel/generic/DADDTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/DADDTestCase.java
@@ -22,7 +22,7 @@
public class DADDTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final DADD dadd = new DADD();
dadd.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/DDIVTestCase.java b/src/test/java/org/apache/bcel/generic/DDIVTestCase.java
index 967135cea8..9a7631f8d1 100644
--- a/src/test/java/org/apache/bcel/generic/DDIVTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/DDIVTestCase.java
@@ -22,7 +22,7 @@
public class DDIVTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final DDIV ddiv = new DDIV();
ddiv.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/DMULTestCase.java b/src/test/java/org/apache/bcel/generic/DMULTestCase.java
index 4a0e889d03..fae37aaeca 100644
--- a/src/test/java/org/apache/bcel/generic/DMULTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/DMULTestCase.java
@@ -22,7 +22,7 @@
public class DMULTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final DMUL dmul = new DMUL();
dmul.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/DNEGTestCase.java b/src/test/java/org/apache/bcel/generic/DNEGTestCase.java
index dfcc2ae733..48d1114021 100644
--- a/src/test/java/org/apache/bcel/generic/DNEGTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/DNEGTestCase.java
@@ -22,7 +22,7 @@
public class DNEGTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final DNEG dneg = new DNEG();
dneg.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/DREMTestCase.java b/src/test/java/org/apache/bcel/generic/DREMTestCase.java
index 0e8c3bbf81..bc29bf4152 100644
--- a/src/test/java/org/apache/bcel/generic/DREMTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/DREMTestCase.java
@@ -22,7 +22,7 @@
public class DREMTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final DREM drem = new DREM();
drem.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/DSUBTestCase.java b/src/test/java/org/apache/bcel/generic/DSUBTestCase.java
index 9e04ec9b00..0b73263f52 100644
--- a/src/test/java/org/apache/bcel/generic/DSUBTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/DSUBTestCase.java
@@ -22,7 +22,7 @@
public class DSUBTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final DSUB dsub = new DSUB();
dsub.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/EmptyVisitorTestCase.java b/src/test/java/org/apache/bcel/generic/EmptyVisitorTestCase.java
index 36ffcd5d89..cdbb808bb5 100644
--- a/src/test/java/org/apache/bcel/generic/EmptyVisitorTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/EmptyVisitorTestCase.java
@@ -17,15 +17,18 @@
package org.apache.bcel.generic;
import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
import org.apache.bcel.classfile.Code;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;
import org.apache.bcel.util.SyntheticRepository;
+import org.apache.commons.lang3.JavaVersion;
+import org.apache.commons.lang3.SystemUtils;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
-class EmptyVisitorTestCase {
+final class EmptyVisitorTestCase {
/*
* https://docs.oracle.com/javase/specs/jvms/se17/html/jvms-6.html#jvms-6.2
@@ -56,6 +59,8 @@ class EmptyVisitorTestCase {
// @formatter:on
})
public void test(final String className) throws ClassNotFoundException {
+ // "java.io.Bits" is not in Java 21.
+ assumeFalse(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_21) && className.equals("java.io.Bits"));
final JavaClass javaClass = SyntheticRepository.getInstance().loadClass(className);
for (final Method method : javaClass.getMethods()) {
final Code code = method.getCode();
diff --git a/src/test/java/org/apache/bcel/generic/F2DTestCase.java b/src/test/java/org/apache/bcel/generic/F2DTestCase.java
index 02933bc5b9..edb1733f45 100644
--- a/src/test/java/org/apache/bcel/generic/F2DTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/F2DTestCase.java
@@ -22,7 +22,7 @@
public class F2DTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final F2D f2d = new F2D();
f2d.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/F2ITestCase.java b/src/test/java/org/apache/bcel/generic/F2ITestCase.java
index 183fe09d86..dd2c0b7a9a 100644
--- a/src/test/java/org/apache/bcel/generic/F2ITestCase.java
+++ b/src/test/java/org/apache/bcel/generic/F2ITestCase.java
@@ -22,7 +22,7 @@
public class F2ITestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final F2I f2i = new F2I();
f2i.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/F2LTestCase.java b/src/test/java/org/apache/bcel/generic/F2LTestCase.java
index 665fbf2ede..d0dff2af94 100644
--- a/src/test/java/org/apache/bcel/generic/F2LTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/F2LTestCase.java
@@ -22,7 +22,7 @@
public class F2LTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final F2L f2l = new F2L();
f2l.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/FADDTestCase.java b/src/test/java/org/apache/bcel/generic/FADDTestCase.java
index 4b8584b37b..04b9f71691 100644
--- a/src/test/java/org/apache/bcel/generic/FADDTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/FADDTestCase.java
@@ -22,7 +22,7 @@
public class FADDTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final FADD fadd = new FADD();
fadd.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/FDIVTestCase.java b/src/test/java/org/apache/bcel/generic/FDIVTestCase.java
index bb141d424b..106b66f468 100644
--- a/src/test/java/org/apache/bcel/generic/FDIVTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/FDIVTestCase.java
@@ -22,7 +22,7 @@
public class FDIVTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final FDIV fdiv = new FDIV();
fdiv.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/FMULTestCase.java b/src/test/java/org/apache/bcel/generic/FMULTestCase.java
index 3334f9d1b2..e142a783f2 100644
--- a/src/test/java/org/apache/bcel/generic/FMULTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/FMULTestCase.java
@@ -22,7 +22,7 @@
public class FMULTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final FMUL fmul = new FMUL();
fmul.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/FNEGTestCase.java b/src/test/java/org/apache/bcel/generic/FNEGTestCase.java
index ac59cfe278..ae5a9d408b 100644
--- a/src/test/java/org/apache/bcel/generic/FNEGTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/FNEGTestCase.java
@@ -22,7 +22,7 @@
public class FNEGTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final FNEG fneg = new FNEG();
fneg.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/FREMTestCase.java b/src/test/java/org/apache/bcel/generic/FREMTestCase.java
index dc6ac980f5..f2adfe90e5 100644
--- a/src/test/java/org/apache/bcel/generic/FREMTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/FREMTestCase.java
@@ -22,7 +22,7 @@
public class FREMTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final FREM frem = new FREM();
frem.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/FSUBTestCase.java b/src/test/java/org/apache/bcel/generic/FSUBTestCase.java
index a0cb2c9270..3748109254 100644
--- a/src/test/java/org/apache/bcel/generic/FSUBTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/FSUBTestCase.java
@@ -22,7 +22,7 @@
public class FSUBTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final FSUB fsub = new FSUB();
fsub.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/FieldGenTest.java b/src/test/java/org/apache/bcel/generic/FieldGenTest.java
new file mode 100644
index 0000000000..cbf366bbda
--- /dev/null
+++ b/src/test/java/org/apache/bcel/generic/FieldGenTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.generic;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.apache.bcel.classfile.ConstantLong;
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.classfile.Field;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link FieldGen}.
+ */
+public class FieldGenTest {
+
+ @Test
+ @Disabled
+ public void testBCELComparator() throws Exception {
+ final ConstantLong[] constantPool = { new ConstantLong(0), new ConstantLong(0) };
+ final FieldGen obj = new FieldGen(new Field(0, 0, 0, null, new ConstantPool(constantPool)), new ConstantPoolGen(constantPool));
+ assertTrue(FieldGen.getComparator().equals(null, null));
+ assertTrue(FieldGen.getComparator().equals(obj, obj));
+ assertFalse(FieldGen.getComparator().equals(obj, null));
+ assertFalse(FieldGen.getComparator().equals(null, obj));
+ }
+}
diff --git a/src/test/java/org/apache/bcel/generic/GETFIELDTestCase.java b/src/test/java/org/apache/bcel/generic/GETFIELDTestCase.java
index dc65c255c4..cd51449b76 100644
--- a/src/test/java/org/apache/bcel/generic/GETFIELDTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/GETFIELDTestCase.java
@@ -22,7 +22,7 @@
public class GETFIELDTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final GETFIELD getfield = new GETFIELD(0);
getfield.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java b/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java
index a2d7798255..762f6fdbb2 100644
--- a/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java
@@ -390,7 +390,7 @@ public void testGenerateMethodLevelAnnotations1() throws ClassNotFoundException
i = mg.getAnnotationEntries().length;
assertEquals(1, i, "Wrong number of annotations on the main 'MethodGen'");
- assertTrue(wipe("temp1", "HelloWorld.class"));
+ assertTrue(delete("temp1", "HelloWorld.class"));
}
/**
@@ -427,8 +427,8 @@ public void testGenerateMethodLevelAnnotations2() throws ClassNotFoundException
assertEquals(1, mainMethod2.getAnnotationEntries().length, "Wrong number of annotations on the 'MethodGen'");
mainMethod2.removeAnnotationEntries();
assertEquals(0, mainMethod2.getAnnotationEntries().length, 0, "Wrong number of annotations on the 'MethodGen'");
- assertTrue(wipe("temp2", "HelloWorld.class"));
- assertTrue(wipe("temp3", "HelloWorld.class"));
+ assertTrue(delete("temp2", "HelloWorld.class"));
+ assertTrue(delete("temp3", "HelloWorld.class"));
}
/**
@@ -442,7 +442,7 @@ public void testModifyingClasses1() throws ClassNotFoundException {
cgen.addAnnotationEntry(createFruitAnnotation(cp, "Pineapple"));
assertEquals(2, cgen.getAnnotationEntries().length, "Wrong number of annotations");
dumpClass(cgen, "SimpleAnnotatedClass.class");
- assertTrue(wipe("SimpleAnnotatedClass.class"));
+ assertTrue(delete("SimpleAnnotatedClass.class"));
}
/**
@@ -458,7 +458,7 @@ public void testModifyingClasses2() throws ClassNotFoundException {
dumpClass(cgen, "SimpleAnnotatedClass.class");
final JavaClass jc2 = getClassFrom(".", "SimpleAnnotatedClass");
jc2.getAnnotationEntries();
- assertTrue(wipe("SimpleAnnotatedClass.class"));
+ assertTrue(delete("SimpleAnnotatedClass.class"));
// System.err.println(jc2.toString());
}
diff --git a/src/test/java/org/apache/bcel/generic/I2BTestCase.java b/src/test/java/org/apache/bcel/generic/I2BTestCase.java
index f22e201802..26626605be 100644
--- a/src/test/java/org/apache/bcel/generic/I2BTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/I2BTestCase.java
@@ -22,7 +22,7 @@
public class I2BTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final I2B i2b = new I2B();
i2b.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/I2CTestCase.java b/src/test/java/org/apache/bcel/generic/I2CTestCase.java
index ced0675719..7e36950711 100644
--- a/src/test/java/org/apache/bcel/generic/I2CTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/I2CTestCase.java
@@ -22,7 +22,7 @@
public class I2CTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final I2C i2c = new I2C();
i2c.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/I2DTestCase.java b/src/test/java/org/apache/bcel/generic/I2DTestCase.java
index be926229e8..fdca82d347 100644
--- a/src/test/java/org/apache/bcel/generic/I2DTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/I2DTestCase.java
@@ -22,7 +22,7 @@
public class I2DTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final I2D i2d = new I2D();
i2d.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/I2FTestCase.java b/src/test/java/org/apache/bcel/generic/I2FTestCase.java
index a941f9f834..28976dbf78 100644
--- a/src/test/java/org/apache/bcel/generic/I2FTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/I2FTestCase.java
@@ -22,7 +22,7 @@
public class I2FTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final I2F i2f = new I2F();
i2f.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/I2LTestCase.java b/src/test/java/org/apache/bcel/generic/I2LTestCase.java
index 45aafac933..6daffa542b 100644
--- a/src/test/java/org/apache/bcel/generic/I2LTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/I2LTestCase.java
@@ -22,7 +22,7 @@
public class I2LTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final I2L i2l = new I2L();
i2l.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/I2STestCase.java b/src/test/java/org/apache/bcel/generic/I2STestCase.java
index 5e270a6d07..aa80fb4ee9 100644
--- a/src/test/java/org/apache/bcel/generic/I2STestCase.java
+++ b/src/test/java/org/apache/bcel/generic/I2STestCase.java
@@ -22,7 +22,7 @@
public class I2STestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final I2S i2s = new I2S();
i2s.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/IADDTestCase.java b/src/test/java/org/apache/bcel/generic/IADDTestCase.java
index 1bc09a7f9a..79475a2aef 100644
--- a/src/test/java/org/apache/bcel/generic/IADDTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/IADDTestCase.java
@@ -22,7 +22,7 @@
public class IADDTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final IADD iadd = new IADD();
iadd.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/IANDTestCase.java b/src/test/java/org/apache/bcel/generic/IANDTestCase.java
index 40354c32a4..fcef723469 100644
--- a/src/test/java/org/apache/bcel/generic/IANDTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/IANDTestCase.java
@@ -22,7 +22,7 @@
public class IANDTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final IAND iand = new IAND();
iand.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/IDIVTestCase.java b/src/test/java/org/apache/bcel/generic/IDIVTestCase.java
index 1bccfc8d34..dfd582ca48 100644
--- a/src/test/java/org/apache/bcel/generic/IDIVTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/IDIVTestCase.java
@@ -22,7 +22,7 @@
public class IDIVTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final IDIV idiv = new IDIV();
idiv.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/IMPDEP1TestCase.java b/src/test/java/org/apache/bcel/generic/IMPDEP1TestCase.java
index 415fa5e392..28cfb373fb 100644
--- a/src/test/java/org/apache/bcel/generic/IMPDEP1TestCase.java
+++ b/src/test/java/org/apache/bcel/generic/IMPDEP1TestCase.java
@@ -22,7 +22,7 @@
public class IMPDEP1TestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final IMPDEP1 impdep1 = new IMPDEP1();
impdep1.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/IMPDEP2TestCase.java b/src/test/java/org/apache/bcel/generic/IMPDEP2TestCase.java
index 517fa4aa9c..7aef908e8f 100644
--- a/src/test/java/org/apache/bcel/generic/IMPDEP2TestCase.java
+++ b/src/test/java/org/apache/bcel/generic/IMPDEP2TestCase.java
@@ -22,7 +22,7 @@
public class IMPDEP2TestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final IMPDEP2 impdep2 = new IMPDEP2();
impdep2.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/IMULTestCase.java b/src/test/java/org/apache/bcel/generic/IMULTestCase.java
index b898b7dd4d..9f233ed5af 100644
--- a/src/test/java/org/apache/bcel/generic/IMULTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/IMULTestCase.java
@@ -22,7 +22,7 @@
public class IMULTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final IMUL imul = new IMUL();
imul.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/INEGTestCase.java b/src/test/java/org/apache/bcel/generic/INEGTestCase.java
index 253b004487..c6b70752cb 100644
--- a/src/test/java/org/apache/bcel/generic/INEGTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/INEGTestCase.java
@@ -22,7 +22,7 @@
public class INEGTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final INEG ineg = new INEG();
ineg.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/IORTestCase.java b/src/test/java/org/apache/bcel/generic/IORTestCase.java
index 76aa1dd539..9078c8a82d 100644
--- a/src/test/java/org/apache/bcel/generic/IORTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/IORTestCase.java
@@ -22,7 +22,7 @@
public class IORTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final IOR ior = new IOR();
ior.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/IREMTestCase.java b/src/test/java/org/apache/bcel/generic/IREMTestCase.java
index a829539c1c..e00d96364d 100644
--- a/src/test/java/org/apache/bcel/generic/IREMTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/IREMTestCase.java
@@ -22,7 +22,7 @@
public class IREMTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final IREM irem = new IREM();
irem.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/ISHLTestCase.java b/src/test/java/org/apache/bcel/generic/ISHLTestCase.java
index 3d3596d31f..262a1e9adc 100644
--- a/src/test/java/org/apache/bcel/generic/ISHLTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/ISHLTestCase.java
@@ -22,7 +22,7 @@
public class ISHLTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final ISHL ishl = new ISHL();
ishl.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/ISHRTestCase.java b/src/test/java/org/apache/bcel/generic/ISHRTestCase.java
index 0868e3451e..85d2176574 100644
--- a/src/test/java/org/apache/bcel/generic/ISHRTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/ISHRTestCase.java
@@ -22,7 +22,7 @@
public class ISHRTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final ISHR ishr = new ISHR();
ishr.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/ISUBTestCase.java b/src/test/java/org/apache/bcel/generic/ISUBTestCase.java
index ef5012e072..6cc9769936 100644
--- a/src/test/java/org/apache/bcel/generic/ISUBTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/ISUBTestCase.java
@@ -22,7 +22,7 @@
public class ISUBTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final ISUB isub = new ISUB();
isub.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/IXORTestCase.java b/src/test/java/org/apache/bcel/generic/IXORTestCase.java
index 8d27121f29..6c48d971ed 100644
--- a/src/test/java/org/apache/bcel/generic/IXORTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/IXORTestCase.java
@@ -22,7 +22,7 @@
public class IXORTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final IXOR ixor = new IXOR();
ixor.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/InstructionFactoryTestCase.java b/src/test/java/org/apache/bcel/generic/InstructionFactoryTestCase.java
new file mode 100644
index 0000000000..84782d6743
--- /dev/null
+++ b/src/test/java/org/apache/bcel/generic/InstructionFactoryTestCase.java
@@ -0,0 +1,100 @@
+/*
+ * 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.generic;
+
+import static org.apache.bcel.generic.InstructionFactory.createArrayLoad;
+import static org.apache.bcel.generic.InstructionFactory.createArrayStore;
+import static org.apache.bcel.generic.InstructionFactory.createBinaryOperation;
+import static org.apache.bcel.generic.InstructionFactory.createBranchInstruction;
+import static org.apache.bcel.generic.InstructionFactory.createLoad;
+import static org.apache.bcel.generic.InstructionFactory.createNull;
+import static org.apache.bcel.generic.InstructionFactory.createReturn;
+import static org.apache.bcel.generic.InstructionFactory.createStore;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
+
+import org.apache.bcel.AbstractTestCase;
+import org.apache.bcel.Const;
+import org.apache.bcel.Repository;
+import org.junit.jupiter.api.Test;
+
+public class InstructionFactoryTestCase extends AbstractTestCase {
+
+ @Test
+ public void testArrayLoad() throws Exception {
+ assertEquals(InstructionConst.BALOAD, createArrayLoad(Type.BOOLEAN));
+ assertEquals(InstructionConst.BALOAD, createArrayLoad(Type.BYTE));
+ assertEquals(InstructionConst.CALOAD, createArrayLoad(Type.CHAR));
+ assertEquals(InstructionConst.SALOAD, createArrayLoad(Type.SHORT));
+ assertEquals(InstructionConst.IALOAD, createArrayLoad(Type.INT));
+ assertEquals(InstructionConst.FALOAD, createArrayLoad(Type.FLOAT));
+ assertEquals(InstructionConst.DALOAD, createArrayLoad(Type.DOUBLE));
+ assertEquals(InstructionConst.LALOAD, createArrayLoad(Type.LONG));
+ assertEquals(InstructionConst.AALOAD, createArrayLoad(Type.OBJECT));
+ assertEquals(InstructionConst.AALOAD, createArrayLoad(Type.getType("[I")));
+ }
+
+ @Test
+ public void testArrayStore() throws Exception {
+ assertEquals(InstructionConst.BASTORE, createArrayStore(Type.BOOLEAN));
+ assertEquals(InstructionConst.BASTORE, createArrayStore(Type.BYTE));
+ assertEquals(InstructionConst.CASTORE, createArrayStore(Type.CHAR));
+ assertEquals(InstructionConst.SASTORE, createArrayStore(Type.SHORT));
+ assertEquals(InstructionConst.IASTORE, createArrayStore(Type.INT));
+ assertEquals(InstructionConst.FASTORE, createArrayStore(Type.FLOAT));
+ assertEquals(InstructionConst.DASTORE, createArrayStore(Type.DOUBLE));
+ assertEquals(InstructionConst.LASTORE, createArrayStore(Type.LONG));
+ assertEquals(InstructionConst.AASTORE, createArrayStore(Type.OBJECT));
+ assertEquals(InstructionConst.AASTORE, createArrayStore(Type.getType("[I")));
+ }
+
+ @Test
+ public void testExceptions() throws Exception {
+ final InstructionFactory factory = new InstructionFactory(new ClassGen(Repository.lookupClass(Object.class)));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createArrayLoad(Type.UNKNOWN));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createArrayStore(Type.UNKNOWN));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createBinaryOperation("$", Type.DOUBLE));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createBinaryOperation("$", Type.FLOAT));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createBinaryOperation("$", Type.INT));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createBinaryOperation("$", Type.LONG));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createBinaryOperation("*", Type.OBJECT));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createBranchInstruction(Short.MIN_VALUE, null));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createLoad(Type.UNKNOWN, 0));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createNull(Type.UNKNOWN));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createReturn(Type.UNKNOWN));
+ assertThrowsExactly(IllegalArgumentException.class, () -> createStore(Type.UNKNOWN, 0));
+ assertThrowsExactly(IllegalArgumentException.class, () -> factory.createAppend(Type.UNKNOWN));
+ assertThrowsExactly(IllegalArgumentException.class, () -> factory.createCast(Type.UNKNOWN, Type.UNKNOWN));
+ assertThrowsExactly(IllegalArgumentException.class, () -> factory.createFieldAccess("java.lang.System", "out", new ObjectType("java.io.PrintStream"), Const.NOP));
+ assertThrowsExactly(IllegalArgumentException.class, () -> factory.createInvoke("java.io.PrintStream", "println", Type.VOID, new Type[] { Type.STRING }, Const.NOP));
+ }
+
+ @Test
+ public void testNull() throws Exception {
+ assertEquals(InstructionConst.ICONST_0, createNull(Type.BOOLEAN));
+ assertEquals(InstructionConst.ICONST_0, createNull(Type.BYTE));
+ assertEquals(InstructionConst.ICONST_0, createNull(Type.CHAR));
+ assertEquals(InstructionConst.ICONST_0, createNull(Type.SHORT));
+ assertEquals(InstructionConst.ICONST_0, createNull(Type.INT));
+ assertEquals(InstructionConst.FCONST_0, createNull(Type.FLOAT));
+ assertEquals(InstructionConst.DCONST_0, createNull(Type.DOUBLE));
+ assertEquals(InstructionConst.LCONST_0, createNull(Type.LONG));
+ assertEquals(InstructionConst.NOP, createNull(Type.VOID));
+ assertEquals(InstructionConst.ACONST_NULL, createNull(Type.OBJECT));
+ assertEquals(InstructionConst.ACONST_NULL, createNull(Type.getType("[I")));
+ }
+}
diff --git a/src/test/java/org/apache/bcel/generic/JavaHome.java b/src/test/java/org/apache/bcel/generic/JavaHome.java
index d59bc2e4eb..f23be5537a 100644
--- a/src/test/java/org/apache/bcel/generic/JavaHome.java
+++ b/src/test/java/org/apache/bcel/generic/JavaHome.java
@@ -20,8 +20,6 @@
import static com.sun.jna.platform.win32.WinReg.HKEY_LOCAL_MACHINE;
import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -39,6 +37,7 @@
import org.apache.bcel.classfile.Module;
import org.apache.bcel.classfile.Utility;
import org.apache.bcel.util.ModularRuntimeImage;
+import org.apache.commons.io.function.Uncheck;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
@@ -69,12 +68,8 @@ public class JavaHome {
private static Stream find(final Path start, final int maxDepth, final BiPredicate matcher,
final FileVisitOption... options) {
- try {
- // TODO Replace with Apache Commons IO UncheckedFiles later.
- return Files.exists(start) ? Files.find(start, maxDepth, matcher, options) : Stream.empty();
- } catch (final IOException e) {
- throw new UncheckedIOException(e);
- }
+ // TODO Apache Commons 2.14.0: Use FilesUncheck
+ return Files.exists(start) ? Uncheck.apply(Files::find, start, maxDepth, matcher, options) : Stream.empty();
}
private static JavaHome from(final String javaHome) {
@@ -218,11 +213,7 @@ Stream find(final int maxDepth, final BiPredicate new ModularRuntimeImage(path.toString()));
}
Path getPath() {
@@ -258,11 +249,7 @@ private Stream streamModuleByExt() {
}
private JarFile toJarFile(final Path path) {
- try {
- return new JarFile(path.toFile());
- } catch (final IOException e) {
- throw new UncheckedIOException(e);
- }
+ return Uncheck.get(() -> new JarFile(path.toFile()));
}
@Override
diff --git a/src/test/java/org/apache/bcel/generic/JdkGenericDumpTestCase.java b/src/test/java/org/apache/bcel/generic/JdkGenericDumpTestCase.java
index 425a167ad7..67f34a880b 100644
--- a/src/test/java/org/apache/bcel/generic/JdkGenericDumpTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/JdkGenericDumpTestCase.java
@@ -52,7 +52,7 @@
* Test that the generic dump() methods work on the JDK classes Reads each class into an instruction list and then dumps the instructions. The output bytes
* should be the same as the input.
*
- * Set the property {@value JavaHome#EXTRA_JAVA_HOMES} to a {@link File#pathSeparator}-separated list of JRE/JDK paths for additional testing.
+ * Sets the property {@value JavaHome#EXTRA_JAVA_HOMES} to a {@link File#pathSeparator}-separated list of JRE/JDK paths for additional testing.
*
*
* For example:
diff --git a/src/test/java/org/apache/bcel/generic/JiraBcel362TestCase.java b/src/test/java/org/apache/bcel/generic/JiraBcel362TestCase.java
index 9a04f79b80..b7959743c9 100644
--- a/src/test/java/org/apache/bcel/generic/JiraBcel362TestCase.java
+++ b/src/test/java/org/apache/bcel/generic/JiraBcel362TestCase.java
@@ -29,10 +29,12 @@
* the corresponding constant is found after parsing.
*/
public class JiraBcel362TestCase extends AbstractTestCase {
+
@Test
public void testProcessConstantPoolWithCondyEntry() throws ClassNotFoundException {
final JavaClass clazz = getTestJavaClass("issue362.Bcel362");
final ConstantPoolGen constantPoolGen = assertDoesNotThrow(() -> new ConstantPoolGen(clazz.getConstantPool()));
assertTrue(constantPoolGen.lookupUtf8("$jacocoData") != -1);
}
+
}
diff --git a/src/test/java/org/apache/bcel/generic/L2DTestCase.java b/src/test/java/org/apache/bcel/generic/L2DTestCase.java
index 314f1f801a..453b6c4eeb 100644
--- a/src/test/java/org/apache/bcel/generic/L2DTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/L2DTestCase.java
@@ -22,7 +22,7 @@
public class L2DTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final L2D l2d = new L2D();
l2d.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/L2FTestCase.java b/src/test/java/org/apache/bcel/generic/L2FTestCase.java
index 44d4997dac..4b9055c2ba 100644
--- a/src/test/java/org/apache/bcel/generic/L2FTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/L2FTestCase.java
@@ -22,7 +22,7 @@
public class L2FTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final L2F l2f = new L2F();
l2f.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/L2ITestCase.java b/src/test/java/org/apache/bcel/generic/L2ITestCase.java
index 3cfbb8c46c..8d0cccd5f0 100644
--- a/src/test/java/org/apache/bcel/generic/L2ITestCase.java
+++ b/src/test/java/org/apache/bcel/generic/L2ITestCase.java
@@ -22,7 +22,7 @@
public class L2ITestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final L2I l2i = new L2I();
l2i.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LADDTestCase.java b/src/test/java/org/apache/bcel/generic/LADDTestCase.java
index f021c8e64f..6d1276f7ba 100644
--- a/src/test/java/org/apache/bcel/generic/LADDTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LADDTestCase.java
@@ -22,7 +22,7 @@
public class LADDTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LADD ladd = new LADD();
ladd.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LANDTestCase.java b/src/test/java/org/apache/bcel/generic/LANDTestCase.java
index 962543a850..14fdcdd817 100644
--- a/src/test/java/org/apache/bcel/generic/LANDTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LANDTestCase.java
@@ -22,7 +22,7 @@
public class LANDTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LAND land = new LAND();
land.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LCMPTestCase.java b/src/test/java/org/apache/bcel/generic/LCMPTestCase.java
index 3c75fcb9fc..d0c1c0d5ab 100644
--- a/src/test/java/org/apache/bcel/generic/LCMPTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LCMPTestCase.java
@@ -22,7 +22,7 @@
public class LCMPTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LCMP lcmp = new LCMP();
lcmp.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LDIVTestCase.java b/src/test/java/org/apache/bcel/generic/LDIVTestCase.java
index 59467dd458..e1f4e98489 100644
--- a/src/test/java/org/apache/bcel/generic/LDIVTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LDIVTestCase.java
@@ -22,7 +22,7 @@
public class LDIVTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LDIV ldiv = new LDIV();
ldiv.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LMULTestCase.java b/src/test/java/org/apache/bcel/generic/LMULTestCase.java
index 8422b72abc..7d2b1e04c7 100644
--- a/src/test/java/org/apache/bcel/generic/LMULTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LMULTestCase.java
@@ -22,7 +22,7 @@
public class LMULTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LMUL lmul = new LMUL();
lmul.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LNEGTestCase.java b/src/test/java/org/apache/bcel/generic/LNEGTestCase.java
index b87ba6a9e4..df30aca3ba 100644
--- a/src/test/java/org/apache/bcel/generic/LNEGTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LNEGTestCase.java
@@ -22,7 +22,7 @@
public class LNEGTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LNEG lneg = new LNEG();
lneg.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LORTestCase.java b/src/test/java/org/apache/bcel/generic/LORTestCase.java
index 5e0b0382ee..4414104b55 100644
--- a/src/test/java/org/apache/bcel/generic/LORTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LORTestCase.java
@@ -22,7 +22,7 @@
public class LORTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LOR lor = new LOR();
lor.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LREMTestCase.java b/src/test/java/org/apache/bcel/generic/LREMTestCase.java
index ff950d797e..14458e4a95 100644
--- a/src/test/java/org/apache/bcel/generic/LREMTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LREMTestCase.java
@@ -22,7 +22,7 @@
public class LREMTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LREM lrem = new LREM();
lrem.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LSHLTestCase.java b/src/test/java/org/apache/bcel/generic/LSHLTestCase.java
index 507b6fc158..6cda61d6b9 100644
--- a/src/test/java/org/apache/bcel/generic/LSHLTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LSHLTestCase.java
@@ -22,7 +22,7 @@
public class LSHLTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LSHL lshl = new LSHL();
lshl.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LSHRTestCase.java b/src/test/java/org/apache/bcel/generic/LSHRTestCase.java
index 7a4276cced..ae1fb212a0 100644
--- a/src/test/java/org/apache/bcel/generic/LSHRTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LSHRTestCase.java
@@ -22,7 +22,7 @@
public class LSHRTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LSHR lshr = new LSHR();
lshr.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LSUBTestCase.java b/src/test/java/org/apache/bcel/generic/LSUBTestCase.java
index 46a154f565..17b3a342e3 100644
--- a/src/test/java/org/apache/bcel/generic/LSUBTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LSUBTestCase.java
@@ -22,7 +22,7 @@
public class LSUBTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LSUB lsub = new LSUB();
lsub.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LXORTestCase.java b/src/test/java/org/apache/bcel/generic/LXORTestCase.java
index 4d8578a002..3492b2bd83 100644
--- a/src/test/java/org/apache/bcel/generic/LXORTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/LXORTestCase.java
@@ -22,7 +22,7 @@
public class LXORTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final LXOR lxor = new LXOR();
lxor.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/LargeJump.java b/src/test/java/org/apache/bcel/generic/LargeJump.java
index e03aed6a7e..31a82e160b 100644
--- a/src/test/java/org/apache/bcel/generic/LargeJump.java
+++ b/src/test/java/org/apache/bcel/generic/LargeJump.java
@@ -16,7 +16,7 @@
*/
package org.apache.bcel.generic;
-class LargeJump {
+final class LargeJump {
public static void methodWithLargeJump(final int i) {
for (; i == 0;) {
try {
diff --git a/src/test/java/org/apache/bcel/generic/PUTFIELDTestCase.java b/src/test/java/org/apache/bcel/generic/PUTFIELDTestCase.java
index 373471083e..71796bf87f 100644
--- a/src/test/java/org/apache/bcel/generic/PUTFIELDTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/PUTFIELDTestCase.java
@@ -22,7 +22,7 @@
public class PUTFIELDTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final PUTFIELD putfield = new PUTFIELD(0);
putfield.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/PUTSTATICTestCase.java b/src/test/java/org/apache/bcel/generic/PUTSTATICTestCase.java
index e8bf44246d..e4cbb839fd 100644
--- a/src/test/java/org/apache/bcel/generic/PUTSTATICTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/PUTSTATICTestCase.java
@@ -22,7 +22,7 @@
public class PUTSTATICTestCase {
@Test
- public void accept() {
+ public void testAccept() {
final CountingVisitor countVisitor = new CountingVisitor();
final PUTSTATIC putstatic = new PUTSTATIC(0);
putstatic.accept(countVisitor);
diff --git a/src/test/java/org/apache/bcel/generic/TypeTestCase.java b/src/test/java/org/apache/bcel/generic/TypeTestCase.java
index a2632151de..303a75ba4c 100644
--- a/src/test/java/org/apache/bcel/generic/TypeTestCase.java
+++ b/src/test/java/org/apache/bcel/generic/TypeTestCase.java
@@ -17,8 +17,15 @@
package org.apache.bcel.generic;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
public class TypeTestCase {
@Test
@@ -32,4 +39,64 @@ public void testBCEL243() {
assertEquals(expectedValue, actualValue, "Type.getType");
}
+ @Test
+ public void testInternalTypeNametoSignature() {
+ assertEquals(null, Type.internalTypeNameToSignature(null));
+ assertEquals("", Type.internalTypeNameToSignature(""));
+ assertEquals("TT;", Type.internalTypeNameToSignature("TT;"));
+ assertEquals("Ljava/lang/String;", Type.internalTypeNameToSignature("Ljava/lang/String;"));
+ assertEquals("[Ljava/lang/String;", Type.internalTypeNameToSignature("[Ljava/lang/String;"));
+ assertEquals("Ljava/lang/String;", Type.internalTypeNameToSignature("java/lang/String"));
+ assertEquals("I", Type.internalTypeNameToSignature("I"));
+ assertEquals("LT;", Type.internalTypeNameToSignature("T"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ // @formatter:off
+ "java/io/Externalizable",
+ "java/io/ObjectOutputStream",
+ "java/io/Serializable",
+ "java/lang/Cloneable",
+ "java/lang/RuntimeException",
+ "java/lang/String",
+ "java/lang/System",
+ "java/lang/Throwable",
+ "java/net/URI",
+ "java/sql/Statement",
+ "java/util/ArrayList",
+ "java/util/Calendar",
+ "java/util/EnumMap",
+ "java/util/HashSet",
+ "java/util/Iterator",
+ "java/util/LinkedList",
+ "java/util/List",
+ "java/util/Map",
+ "java/util/concurrent/ConcurrentMap",
+ "java/util/concurrent/ExecutorService",
+ "org/apache/bcel/classfile/JavaClass",
+ "org/apache/bcel/classfile/Method",
+ "org/apache/bcel/classfile/Synthetic",
+ "org/apache/bcel/generic/ConstantPoolGen",
+ "org/apache/bcel/generic/MethodGen",
+ "com/foo/Foo"})
+ // @formatter:on
+ public void testLDC(final String className) throws Exception {
+ final JavaClass jc = Repository.lookupClass(className);
+ final ConstantPoolGen cpg = new ConstantPoolGen(jc.getConstantPool());
+ for (final Method method : jc.getMethods()) {
+ final Code code = method.getCode();
+ if (code != null) {
+ final InstructionList instructionList = new InstructionList(code.getCode());
+ for (final InstructionHandle instructionHandle : instructionList) {
+ instructionHandle.accept(new EmptyVisitor() {
+ @Override
+ public void visitLDC(final LDC obj) {
+ assertNotNull(obj.getValue(cpg));
+ }
+ });
+ }
+ }
+ }
+ }
}
diff --git a/src/test/java/org/apache/bcel/util/BCELifierTestCase.java b/src/test/java/org/apache/bcel/util/BCELifierTestCase.java
index 24d2eb2e97..8ab68d6c6d 100644
--- a/src/test/java/org/apache/bcel/util/BCELifierTestCase.java
+++ b/src/test/java/org/apache/bcel/util/BCELifierTestCase.java
@@ -42,7 +42,7 @@
public class BCELifierTestCase extends AbstractTestCase {
private static final String EOL = System.lineSeparator();
- public static final String CLASSPATH = System.getProperty("java.class.path") + File.pathSeparator + ".";
+ public static final String CLASSPATH = "." + File.pathSeparator + System.getProperty("java.class.path");
// Canonicalise the javap output so it compares better
private String canonHashRef(String input) {
@@ -173,8 +173,9 @@ public void testHelloWorld() throws Exception {
}
/*
- * Dump a class using "javap" and compare with the same class recreated using BCELifier, "javac", "java" and dumped with
- * "javap" TODO: detect if JDK present and skip test if not
+ * Dumps a class using "javap" and compare with the same class recreated using BCELifier, "javac", "java" and dumped with "javap".
+ *
+ * TODO: detect if JDK present and skip test if not
*/
@ParameterizedTest
@ValueSource(strings = {
@@ -208,6 +209,14 @@ public void testMainNoArg() throws Exception {
}
}
+ @ParameterizedTest
+ @ValueSource(strings = { "StackMapExample", "StackMapExample2" })
+ public void testStackMap(final String className) throws Exception {
+ testJavapCompare(className);
+ final File workDir = new File("target");
+ assertEquals("Hello World" + EOL, exec(workDir, "java", "-cp", CLASSPATH, className, "Hello"));
+ }
+
@Test
public void testStart() throws Exception {
final OutputStream os = new ByteArrayOutputStream();
diff --git a/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java b/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
index e920c747e0..4f1790a034 100644
--- a/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
+++ b/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
@@ -25,21 +25,29 @@
import org.apache.bcel.Constants;
import org.apache.bcel.classfile.ClassParser;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
public class Class2HTMLTestCase {
- @Test
- public void testConvertJavaUtil() throws Exception {
+ @ParameterizedTest
+ @ValueSource(strings = {
+ // @formatter:off
+ "target/test-classes/Java8Example.class",
+ "target/test-classes/Java4Example.class"})
+ // @formatter:on
+ public void testConvertJavaUtil(final String classFileName) throws Exception {
final File outputDir = new File("target/test-output/html");
if (!outputDir.mkdirs()) { // either was not created or already existed
assertTrue(outputDir.isDirectory()); // fail if missing
}
- try (FileInputStream file = new FileInputStream("target/test-classes/Java8Example.class")) {
+ try (FileInputStream file = new FileInputStream(classFileName)) {
- final ClassParser parser = new ClassParser(file, "Java8Example.class");
+ final ClassParser parser = new ClassParser(file, new File(classFileName).getName());
new Class2HTML(parser.parse(), outputDir.getAbsolutePath() + "/");
+ // TODO assertions on generated HTML code
}
}
diff --git a/src/test/java/org/apache/bcel/verifier/JiraBcel369TestCase.java b/src/test/java/org/apache/bcel/verifier/JiraBcel369TestCase.java
new file mode 100644
index 0000000000..5a8502d173
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/JiraBcel369TestCase.java
@@ -0,0 +1,121 @@
+/*
+ * 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.verifier;
+
+import org.apache.bcel.AbstractTestCase;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests BCEL-369.
+ */
+public class JiraBcel369TestCase extends AbstractTestCase {
+
+ @Test
+ public void testCompileAndVerify() throws ClassNotFoundException {
+ Verifier.verifyType(org.apache.bcel.verifier.JiraBcel369TestFixture.class.getName());
+ }
+
+ /**
+ * 3.7.0 fails with
+ *
{@code
+ * org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL ERROR: Some RuntimeException occurred while verify()ing class 'issue369.Test', method 'public void (int arg1)'. Original RuntimeException's stack trace:
+---
+org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL ERROR: outFrame not set! This:
+ 24: return [InstructionContext]
+ExecutionChain: 24: return [InstructionContext]
+OutFrames: '{ 7: jsr -> 19 [InstructionContext]=Local Variables:
+0: issue369.Test
+1: int
+2:
+3: 34>
+4:
+OperandStack:
+Slots used: 0 MaxStack: 1.
+, 14: jsr -> 19 [InstructionContext]=Local Variables:
+0: issue369.Test
+1: int
+2: java.lang.Throwable
+3:
+4:
+OperandStack:
+Slots used: 0 MaxStack: 1.
+}'.
+ at org.apache.bcel.verifier.structurals.ControlFlowGraph$InstructionContextImpl.getOutFrame(ControlFlowGraph.java:282)
+ at org.apache.bcel.verifier.structurals.Pass3bVerifier.circulationPump(Pass3bVerifier.java:275)
+ at org.apache.bcel.verifier.structurals.Pass3bVerifier.do_verify(Pass3bVerifier.java:386)
+ at org.apache.bcel.verifier.PassVerifier.verify(PassVerifier.java:98)
+ at org.apache.bcel.verifier.Verifier.doPass3b(Verifier.java:166)
+ at org.apache.bcel.verifier.Verifier.verifyType(Verifier.java:90)
+ at org.apache.bcel.verifier.JiraBcel369TestCase.testCompiledClass(JiraBcel369TestCase.java:35)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+ at java.lang.reflect.Method.invoke(Method.java:498)
+ at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
+ ...
+ at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
+---
+
+ at org.apache.bcel.verifier.structurals.Pass3bVerifier.do_verify(Pass3bVerifier.java:398)
+ at org.apache.bcel.verifier.PassVerifier.verify(PassVerifier.java:98)
+ at org.apache.bcel.verifier.Verifier.doPass3b(Verifier.java:166)
+ at org.apache.bcel.verifier.Verifier.verifyType(Verifier.java:90)
+ at org.apache.bcel.verifier.JiraBcel369TestCase.testCompiledClass(JiraBcel369TestCase.java:35)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+ at java.lang.reflect.Method.invoke(Method.java:498)
+ at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
+ ...
+ at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
+Caused by: org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL ERROR: outFrame not set! This:
+ 24: return [InstructionContext]
+ExecutionChain: 24: return [InstructionContext]
+OutFrames: '{ 7: jsr -> 19 [InstructionContext]=Local Variables:
+0: issue369.Test
+1: int
+2:
+3: 34>
+4:
+OperandStack:
+Slots used: 0 MaxStack: 1.
+, 14: jsr -> 19 [InstructionContext]=Local Variables:
+0: issue369.Test
+1: int
+2: java.lang.Throwable
+3:
+4:
+OperandStack:
+Slots used: 0 MaxStack: 1.
+}'.
+ at org.apache.bcel.verifier.structurals.ControlFlowGraph$InstructionContextImpl.getOutFrame(ControlFlowGraph.java:282)
+ at org.apache.bcel.verifier.structurals.Pass3bVerifier.circulationPump(Pass3bVerifier.java:275)
+ at org.apache.bcel.verifier.structurals.Pass3bVerifier.do_verify(Pass3bVerifier.java:386)
+ ... 74 more
+ * }
+ *
+ * @throws ClassNotFoundException
+ */
+ @Test
+ @Disabled
+ public void testCompiledClass() throws ClassNotFoundException {
+ Verifier.verifyType("issue369.Test");
+ }
+
+}
diff --git a/src/test/java/org/apache/bcel/verifier/JiraBcel369TestFixture.java b/src/test/java/org/apache/bcel/verifier/JiraBcel369TestFixture.java
new file mode 100644
index 0000000000..203ffd6680
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/JiraBcel369TestFixture.java
@@ -0,0 +1,35 @@
+/*
+ * 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.verifier;
+
+final class JiraBcel369TestFixture {
+
+ public JiraBcel369TestFixture(int i) {
+ try {
+ i++;
+ } finally {
+ if (i == 0) {
+ return;
+ }
+ int u = 7;
+ u += 9;
+ }
+ i++;
+ }
+
+}
diff --git a/src/test/java/org/apache/bcel/verifier/JiraBcel370TestCase.java b/src/test/java/org/apache/bcel/verifier/JiraBcel370TestCase.java
new file mode 100644
index 0000000000..a92a92240f
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/JiraBcel370TestCase.java
@@ -0,0 +1,79 @@
+/*
+ * 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.verifier;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import org.apache.bcel.AbstractTestCase;
+import org.apache.bcel.classfile.ClassParser;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.EmptyVisitor;
+import org.apache.bcel.generic.Instruction;
+import org.apache.bcel.generic.LDC;
+import org.apache.bcel.generic.MethodGen;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+/**
+ * Tests BCEL-370.
+ */
+public class JiraBcel370TestCase extends AbstractTestCase {
+ @ParameterizedTest
+ @ValueSource(strings = {
+ // @formatter:off
+ "target/test-classes/com/puppycrawl/tools/checkstyle/grammar/java/JavaLanguageParser$ClassBlockContext.class",
+ "target/test-classes/com/foo/Foo.class"
+ })
+ // @formatter:on
+ public void testLdcGetType(final String classFileName) throws Exception {
+ try (FileInputStream file = new FileInputStream(classFileName)) {
+ final ClassParser parser = new ClassParser(file, new File(classFileName).getName());
+ final JavaClass clazz = parser.parse();
+
+ final Method[] methods = clazz.getMethods();
+
+ final ConstantPoolGen cp = new ConstantPoolGen(clazz.getConstantPool());
+ final MethodGen methodGen = new MethodGen(methods[0], classFileName, cp);
+
+ // The first instruction is an LDC CONSTANT_Dynamic added by Jacoco
+ final Instruction instruction = methodGen.getInstructionList().getInstructions()[0];
+
+ instruction.accept(new EmptyVisitor() {
+ @Override
+ public void visitLDC(final LDC ldc) {
+ // Without the change to LDC.getType() this fails because the tag is CONSTANT_Dynamic
+ ldc.getType(cp);
+ }
+ });
+ }
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ // @formatter:off
+ "com.foo.Foo"
+ })
+ // @formatter:on
+ public void testVerify(final String className) throws ClassNotFoundException {
+ // Without the changes to the verifier this fails because it doesn't allow LDC CONSTANT_Dynamic
+ Verifier.verifyType(className);
+ }
+}
diff --git a/src/test/java/org/apache/bcel/verifier/VerifierMainTestCase.java b/src/test/java/org/apache/bcel/verifier/VerifierMainTestCase.java
new file mode 100644
index 0000000000..f1b4b4ff6d
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/VerifierMainTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * 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.verifier;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.bcel.AbstractTestCase;
+import org.apache.bcel.classfile.ClassParser;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.generic.EmptyVisitor;
+import org.apache.bcel.generic.InstructionHandle;
+import org.apache.bcel.generic.InstructionList;
+import org.apache.bcel.generic.SWAP;
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.jdt.internal.compiler.batch.Main;
+import org.junit.jupiter.api.Test;
+
+public class VerifierMainTestCase extends AbstractTestCase {
+
+ @Test
+ public void testSWAP() throws Exception {
+ final String[] argv = { "src/test/java/org/apache/bcel/data/SWAP.java", "-g", "-source", "1.4", "-target", "1.4", "-d", "target/test-classes" };
+ new Main(new PrintWriter(System.out), new PrintWriter(System.err), false/*systemExit*/, null/*options*/, null/*progress*/).compile(argv);
+ final String javaAgent = getJavaAgent();
+ final List args = new ArrayList<>();
+ args.add("java");
+ if (javaAgent != null) {
+ 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("org.apache.bcel.verifier.Verifier");
+ args.add("org/apache/bcel/data/SWAP.class");
+ final ProcessBuilder pb = new ProcessBuilder(args);
+ pb.redirectErrorStream(true);
+ final Process p = pb.start();
+ try (BufferedInputStream is = new BufferedInputStream(p.getInputStream())) {
+ final byte[] buff = new byte[2048];
+ final StringBuilder sb = new StringBuilder();
+ for (int len; (len = is.read(buff)) != -1;) {
+ sb.append(new String(buff, 0, len));
+ }
+ final String output = sb.toString();
+ assertEquals(0, p.waitFor(), output);
+ assertEquals(0, StringUtils.countMatches(output, "VERIFIED_REJECTED"), output);
+ assertEquals(6, StringUtils.countMatches(output, "VERIFIED_OK"), output);
+ }
+ // Class has passed the JustIce verifier, but now we need to ensure that the SWAP instruction is in the compiled class.
+ final List swapInstructionsList = new ArrayList<>();
+ final EmptyVisitor swapCollector = new EmptyVisitor() {
+ @Override
+ public void visitSWAP(final SWAP obj) {
+ swapInstructionsList.add(obj);
+ super.visitSWAP(obj);
+ }
+ };
+ try (InputStream in = Files.newInputStream(Paths.get("target/test-classes/org/apache/bcel/data/SWAP.class"))) {
+ final ClassParser classParser = new ClassParser(in, "SWAP.class");
+ final JavaClass javaClass = classParser.parse();
+ final Method method = javaClass.getMethod(org.apache.bcel.data.SWAP.class.getMethod("getTestConstructor", Class.class));
+ final byte[] code = method.getCode().getCode();
+ final InstructionList instructionList = new InstructionList(code);
+ for (final InstructionHandle instructionHandle : instructionList) {
+ instructionHandle.accept(swapCollector);
+ }
+ }
+ assertEquals(1, swapInstructionsList.size());
+ }
+}
diff --git a/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java b/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java
index 2689c5f705..7b76208158 100644
--- a/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java
+++ b/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java
@@ -20,6 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
@@ -33,10 +34,14 @@
import org.apache.bcel.classfile.NestHost;
import org.apache.bcel.classfile.Utility;
import org.apache.bcel.verifier.exc.AssertionViolatedException;
+import org.apache.bcel.verifier.input.FieldVerifierChildClass;
+import org.apache.bcel.verifier.input.StaticFieldVerifierChildClass;
import org.apache.bcel.verifier.statics.StringRepresentation;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledForJreRange;
+import org.junit.jupiter.api.condition.JRE;
public class VerifierTestCase {
@@ -117,7 +122,7 @@ public void testCollection() throws ClassNotFoundException {
}
@Test
- public void testCommonsLang1() throws IOException, URISyntaxException, ClassNotFoundException {
+ public void testCommonsLang2() throws IOException, URISyntaxException, ClassNotFoundException {
testJarFile(getJarFile(org.apache.commons.lang.StringUtils.class), "ArrayUtils", "SerializationUtils");
}
@@ -126,6 +131,33 @@ public void testDefinitionImpl() throws ClassNotFoundException {
testNestHostWithJavaVersion("com.ibm.wsdl.DefinitionImpl");
}
+ @Test
+ public void testJvmOpCodes() throws ClassNotFoundException {
+ testDefaultMethodValidation("org.apache.bcel.verifier.tests.JvmOpCodes");
+ }
+
+ @Test
+ @DisabledForJreRange(max = JRE.JAVA_8)
+ public void testObjectInputStream() throws ClassNotFoundException {
+ testNestHostWithJavaVersion("java.io.ObjectInputStream");
+ }
+
+ @Test
+ @DisabledForJreRange(min = JRE.JAVA_9)
+ public void testObjectInputStreamJDK8() {
+ assertThrowsExactly(UnsupportedOperationException.class, () -> testNestHostWithJavaVersion("java.io.ObjectInputStream"));
+ }
+
+ @Test
+ public void testPackagePrivateField() throws ClassNotFoundException {
+ testDefaultMethodValidation(FieldVerifierChildClass.class.getName());
+ }
+
+ @Test
+ public void testPackagePrivateStaticField() throws ClassNotFoundException {
+ testDefaultMethodValidation(StaticFieldVerifierChildClass.class.getName());
+ }
+
@Test
public void testWSDL() throws IOException, URISyntaxException, ClassNotFoundException {
testJarFile(getJarFile(javax.wsdl.Port.class), "WSDLReaderImpl", "DefinitionImpl");
diff --git a/src/test/java/org/apache/bcel/verifier/VerifierThrowTestCase.java b/src/test/java/org/apache/bcel/verifier/VerifierThrowTestCase.java
new file mode 100644
index 0000000000..7c14e705cf
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/VerifierThrowTestCase.java
@@ -0,0 +1,31 @@
+/*
+ * 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.verifier;
+
+import java.io.IOException;
+
+import org.apache.bcel.verifier.tests.TestThrow01Creator;
+import org.junit.jupiter.api.Test;
+
+public class VerifierThrowTestCase extends AbstractVerifierTestCase {
+ @Test
+ public void testThrowEmptyStack() throws IOException, ClassNotFoundException {
+ new TestThrow01Creator().create();
+ assertVerifyRejected("TestThrow01", "Verification of a method with ATHROW instruction on an empty stack must fail.");
+ }
+}
diff --git a/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java b/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java
index 688e173763..46af8c80fd 100644
--- a/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java
+++ b/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java
@@ -185,10 +185,10 @@ public void testB337() {
*/
private void testVerify(final String directory, final String className) {
final String baseDir = "target/test-classes";
- final String testDir = baseDir + (directory.isEmpty() ? "" : "/" + directory);
+ final String testDir = baseDir + (directory.isEmpty() ? "" : File.separator + directory);
- final File origFile = new File(testDir + "/" + className + ".classx");
- final File testFile = new File(testDir + "/" + className + JavaClass.EXTENSION);
+ final File origFile = new File(testDir, className + ".classx");
+ final File testFile = new File(testDir, className + JavaClass.EXTENSION);
if (!origFile.renameTo(testFile)) {
fail("Failed to rename orig file");
diff --git a/src/test/java/org/apache/bcel/verifier/input/FieldVerifierChildClass.java b/src/test/java/org/apache/bcel/verifier/input/FieldVerifierChildClass.java
new file mode 100644
index 0000000000..390fd54f7f
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/input/FieldVerifierChildClass.java
@@ -0,0 +1,49 @@
+/*
+ * 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.verifier.input;
+
+public class FieldVerifierChildClass extends FieldVerifierSuperClass {
+
+ public FieldVerifierChildClass(final FieldVerifierChildClass c) {
+ super(c.publicField, c.getPrivateField(), c.protectedField, c.packagePrivateField);
+ }
+
+ public int getPackagePrivateField() {
+ return packagePrivateField;
+ }
+
+ public int getProtectedField() {
+ return protectedField;
+ }
+
+ public int getPublicField() {
+ return publicField;
+ }
+
+ public void setPackagePrivateField(final int packagePrivateField) {
+ this.packagePrivateField = packagePrivateField;
+ }
+
+ public void setProtectedField(final int protectedField) {
+ this.protectedField = protectedField;
+ }
+
+ public void setPublicField(final int publicField) {
+ this.publicField = publicField;
+ }
+}
diff --git a/src/test/java/org/apache/bcel/verifier/input/FieldVerifierSuperClass.java b/src/test/java/org/apache/bcel/verifier/input/FieldVerifierSuperClass.java
new file mode 100644
index 0000000000..be33689738
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/input/FieldVerifierSuperClass.java
@@ -0,0 +1,37 @@
+/*
+ * 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.verifier.input;
+
+public class FieldVerifierSuperClass {
+
+ public int publicField;
+ private final int privateField;
+ protected int protectedField;
+ int packagePrivateField;
+
+ public FieldVerifierSuperClass(final int publicField, final int privateField, final int protectedField, final int packagePrivateField) {
+ this.publicField = publicField;
+ this.privateField = privateField;
+ this.protectedField = protectedField;
+ this.packagePrivateField = packagePrivateField;
+ }
+
+ public int getPrivateField() {
+ return privateField;
+ }
+}
diff --git a/src/test/java/org/apache/bcel/verifier/input/StaticFieldVerifierChildClass.java b/src/test/java/org/apache/bcel/verifier/input/StaticFieldVerifierChildClass.java
new file mode 100644
index 0000000000..075fdd0375
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/input/StaticFieldVerifierChildClass.java
@@ -0,0 +1,50 @@
+/*
+ * 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.verifier.input;
+
+public class StaticFieldVerifierChildClass extends StaticFieldVerifierSuperClass {
+
+ public static int getPackagePrivateField() {
+ return packagePrivateField;
+ }
+
+ public static int getProtectedField() {
+ return protectedField;
+ }
+
+ public static int getPublicField() {
+ return publicField;
+ }
+
+ public static void setPackagePrivateField(final int packagePrivateField) {
+ StaticFieldVerifierChildClass.packagePrivateField = packagePrivateField;
+ }
+
+ public static void setProtectedField(final int protectedField) {
+ StaticFieldVerifierChildClass.protectedField = protectedField;
+ }
+
+ public static void setPublicField(final int publicField) {
+ StaticFieldVerifierChildClass.publicField = publicField;
+ }
+
+ @SuppressWarnings("static-access")
+ public StaticFieldVerifierChildClass(final StaticFieldVerifierChildClass c) {
+ super(c.publicField, c.getPrivateField(), c.protectedField, c.packagePrivateField);
+ }
+}
diff --git a/src/test/java/org/apache/bcel/verifier/input/StaticFieldVerifierSuperClass.java b/src/test/java/org/apache/bcel/verifier/input/StaticFieldVerifierSuperClass.java
new file mode 100644
index 0000000000..88eb783941
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/input/StaticFieldVerifierSuperClass.java
@@ -0,0 +1,38 @@
+/*
+ * 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.verifier.input;
+
+public class StaticFieldVerifierSuperClass {
+
+ public static int publicField;
+ private static int privateField;
+ protected static int protectedField;
+ static int packagePrivateField;
+
+ @SuppressWarnings("static-access")
+ public StaticFieldVerifierSuperClass(final int publicField, final int privateField, final int protectedField, final int packagePrivateField) {
+ this.publicField = publicField;
+ this.privateField = privateField;
+ this.protectedField = protectedField;
+ this.packagePrivateField = packagePrivateField;
+ }
+
+ public int getPrivateField() {
+ return privateField;
+ }
+}
diff --git a/src/test/java/org/apache/bcel/verifier/statics/Pass3aVerifierTestCase.java b/src/test/java/org/apache/bcel/verifier/statics/Pass3aVerifierTestCase.java
new file mode 100644
index 0000000000..c368c392c4
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/statics/Pass3aVerifierTestCase.java
@@ -0,0 +1,135 @@
+/*
+ * 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.verifier.statics;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.stream.Stream;
+
+import org.apache.bcel.Const;
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.Attribute;
+import org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.CodeException;
+import org.apache.bcel.classfile.Constant;
+import org.apache.bcel.classfile.ConstantDouble;
+import org.apache.bcel.classfile.ConstantFieldref;
+import org.apache.bcel.classfile.ConstantInterfaceMethodref;
+import org.apache.bcel.classfile.ConstantInvokeDynamic;
+import org.apache.bcel.classfile.ConstantLong;
+import org.apache.bcel.classfile.ConstantMethodHandle;
+import org.apache.bcel.classfile.ConstantMethodType;
+import org.apache.bcel.classfile.ConstantModule;
+import org.apache.bcel.classfile.ConstantNameAndType;
+import org.apache.bcel.classfile.ConstantPackage;
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.classfile.ConstantUtf8;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.util.SyntheticRepository;
+import org.apache.bcel.verifier.VerificationResult;
+import org.apache.bcel.verifier.Verifier;
+import org.apache.bcel.verifier.VerifierFactory;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+class Pass3aVerifierTestCase {
+ public static Stream constantsNotSupportedByLdc() {
+ return Stream.of(
+ new ConstantFieldref(0, 0),
+ new ConstantInterfaceMethodref(0, 0),
+ new ConstantInvokeDynamic(0, 0),
+ new ConstantMethodHandle(0, 0),
+ new ConstantDouble(0D),
+ new ConstantLong(0L),
+ new ConstantMethodHandle(0, 0),
+ new ConstantMethodType(0),
+ new ConstantModule(0),
+ new ConstantNameAndType(0, 0),
+ new ConstantPackage(0),
+ new ConstantUtf8("constant")
+ );
+ }
+ @AfterAll
+ public static void restoreRepository() {
+ // We have set our mock repository, revert the change
+ Repository.setRepository(SyntheticRepository.getInstance());
+ }
+ private Verifier verifier;
+ private org.apache.bcel.util.Repository repository;
+
+ private ConstantPool cp;
+
+ private JavaClass javaClass;
+
+ @ParameterizedTest
+ @MethodSource("constantsNotSupportedByLdc")
+ public void rejectLdcConstant(final Constant constant) {
+ // LDC the constant 0 and then return
+ final byte[] methodCode = {
+ Const.LDC,
+ 0,
+ 0,
+ (byte) Const.RETURN,
+ };
+
+ final Code code = new Code(0, 0, 0, 0, methodCode, new CodeException[0], new Attribute[0], cp);
+
+ when(cp.getConstantPool()).thenReturn(new Constant[] {constant});
+
+ final Attribute[] attributes = {code};
+ final Method method = new Method(0, 0, 0, attributes, cp);
+
+ when(javaClass.getMethods()).thenReturn(new Method[] {method});
+
+ final Pass3aVerifier pass3aVerifier = new Pass3aVerifier(verifier, 0);
+ final VerificationResult verificationResult = pass3aVerifier.do_verify();
+
+ assertThat(verificationResult.getStatus()).isEqualTo(VerificationResult.VERIFIED_REJECTED);
+ assertThat(verificationResult.getMessage()).startsWith("Instruction ldc[18](2) 0 constraint violated: Operand of LDC");
+ }
+
+ @BeforeEach
+ void setup() throws ClassNotFoundException {
+ final String className = "org.apache.bcel.verifier.statics.Pass3aVerifierTestCase.foo";
+
+ verifier = spy(VerifierFactory.getVerifier(className));
+ repository = mock(org.apache.bcel.util.Repository.class);
+ cp = mock(ConstantPool.class);
+ javaClass = mock(JavaClass.class);
+
+ // Mock the verifier
+ doReturn(VerificationResult.VR_OK).when(verifier).doPass2();
+
+ // Mock the repository
+ Repository.setRepository(repository);
+ when(repository.loadClass(className)).thenReturn(javaClass);
+
+ // Mock the constant pool
+ when(cp.getConstantPool()).thenReturn(new Constant[] {new ConstantModule(0)});
+
+ // Mock the java class
+ when(javaClass.getConstantPool()).thenReturn(cp);
+ }
+}
+
diff --git a/src/test/java/org/apache/bcel/verifier/structurals/InstConstraintVisitorTestCase.java b/src/test/java/org/apache/bcel/verifier/structurals/InstConstraintVisitorTestCase.java
new file mode 100644
index 0000000000..72d4c04b6e
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/structurals/InstConstraintVisitorTestCase.java
@@ -0,0 +1,52 @@
+/*
+ * 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.verifier.structurals;
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.bcel.classfile.Constant;
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.LDC;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+public class InstConstraintVisitorTestCase {
+ private ConstantPoolGen cp;
+
+ @ParameterizedTest
+ @MethodSource("org.apache.bcel.verifier.statics.Pass3aVerifierTestCase#constantsNotSupportedByLdc")
+ public void rejectLdcConstantModule(final Constant constant) {
+ final InstConstraintVisitor visitor = new InstConstraintVisitor();
+
+ cp = mock(ConstantPoolGen.class);
+ when(cp.getConstant(0)).thenReturn(constant);
+
+ visitor.setConstantPoolGen(cp);
+
+ final LDC ldc = new LDC(0);
+
+ assertThatCode(() -> visitor.visitLDC(ldc)).hasMessageStartingWith("Instruction LDC constraint violated: Referenced constant should be a");
+ }
+
+ @BeforeEach
+ public void setup() {
+ cp = mock(ConstantPoolGen.class);
+ }
+}
diff --git a/src/test/java/org/apache/bcel/verifier/tests/JvmOpCodes.java b/src/test/java/org/apache/bcel/verifier/tests/JvmOpCodes.java
new file mode 100644
index 0000000000..b9b94e2ffc
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/tests/JvmOpCodes.java
@@ -0,0 +1,172 @@
+/*
+ * 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.verifier.tests;
+
+import org.apache.bcel.generic.DNEG;
+import org.apache.bcel.generic.DREM;
+import org.apache.bcel.generic.DUP2;
+import org.apache.bcel.generic.DUP2_X1;
+import org.apache.bcel.generic.DUP2_X2;
+import org.apache.bcel.generic.DUP_X2;
+import org.apache.bcel.generic.FADD;
+import org.apache.bcel.generic.FNEG;
+import org.apache.bcel.generic.FREM;
+import org.apache.bcel.generic.FSUB;
+import org.apache.bcel.generic.IUSHR;
+import org.apache.bcel.generic.LAND;
+import org.apache.bcel.generic.LNEG;
+import org.apache.bcel.generic.LOR;
+import org.apache.bcel.generic.LSHL;
+import org.apache.bcel.generic.LUSHR;
+import org.apache.bcel.generic.POP;
+import org.apache.bcel.generic.POP2;
+
+/*
+ * A selection of JVM opcodes, each one in a minimal method.
+ */
+public class JvmOpCodes {
+
+ long l1, l2;
+
+ /**
+ * Tests {@link DNEG}.
+ */
+ double dneg(final double a) {
+ return -a;
+ }
+
+ /**
+ * Tests {@link DREM}.
+ */
+ double drem(final double a, final double b) {
+ return a % b;
+ }
+
+ /**
+ * Tests {@link DUP2}.
+ */
+ long dup2(long a) {
+ return a = a + 1;
+ }
+
+ /**
+ * Tests {@link DUP2_X1}.
+ */
+ void dup2x1(final String[] s) {
+ s[0] += "s"; // Form 1
+ l2 = l1 = 1; // Form 2
+ }
+
+ /**
+ * Tests {@link DUP2_X2}.
+ */
+ long dup2x2(final long[] array, final int i, final long l) {
+ return array[i] = l;
+ }
+
+ /**
+ * Tests {@link DUP_X2}.
+ */
+ int dupx2(final int[] array, final int i, final int l) {
+ return array[i] = l;
+ }
+
+ /**
+ * Tests {@link FADD}.
+ */
+ float fadd(final float a, final float b) {
+ return a + b;
+ }
+
+ /**
+ * Tests {@link FNEG}.
+ */
+ float fneg(final float a) {
+ return -a;
+ }
+
+ /**
+ * Tests {@link FREM}.
+ */
+ float frem(final float a, final float b) {
+ return a % b;
+ }
+
+ /**
+ * Tests {@link FSUB}.
+ */
+ float fsub(final float a, final float b) {
+ return a - b;
+ }
+
+ /**
+ * Tests {@link IUSHR}.
+ */
+ int iushr(final int a, final int b) {
+ return a >>> b;
+ }
+
+ /**
+ * Tests {@link LAND}.
+ */
+ long land(final long a, final long b) {
+ return a & b;
+ }
+
+ /**
+ * Tests {@link LNEG}.
+ */
+ long lneg(final long a) {
+ return -a;
+ }
+
+ /**
+ * Tests {@link LOR}.
+ */
+ long lor(final long a, final long b) {
+ return a | b;
+ }
+
+ /**
+ * Tests {@link LSHL}.
+ */
+ long lshl(final long a, final long b) {
+ return a << b;
+ }
+
+ /**
+ * Tests {@link LUSHR}.
+ */
+ long lushr(final long a, final long b) {
+ return a >>> b;
+ }
+
+ /**
+ * Tests {@link POP}.
+ */
+ void pop() {
+ Math.round(0.5f);
+ }
+
+ /**
+ * Tests {@link POP2}.
+ */
+ void pop2() {
+ Math.round(0.5d);
+ }
+}
diff --git a/src/test/java/org/apache/bcel/verifier/tests/TestThrow01Creator.java b/src/test/java/org/apache/bcel/verifier/tests/TestThrow01Creator.java
new file mode 100644
index 0000000000..bb05a3935d
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/tests/TestThrow01Creator.java
@@ -0,0 +1,47 @@
+/*
+ * 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.verifier.tests;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.bcel.Const;
+import org.apache.bcel.generic.ClassGen;
+import org.apache.bcel.generic.InstructionConst;
+import org.apache.bcel.generic.InstructionList;
+import org.apache.bcel.generic.MethodGen;
+import org.apache.bcel.generic.Type;
+
+public class TestThrow01Creator extends TestCreator {
+ private final ClassGen cg;
+
+ public TestThrow01Creator() {
+ cg = new ClassGen(TEST_PACKAGE + ".TestThrow01", "java.lang.Object", "TestThrow01.java", Const.ACC_PUBLIC | Const.ACC_SUPER, new String[] {});
+ }
+
+ @Override
+ public void create(final OutputStream out) throws IOException {
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_STATIC, Type.VOID, Type.NO_ARGS, new String[0], "b", cg.getClassName(), il, cg.getConstantPool());
+ il.append(InstructionConst.getInstruction(Const.ATHROW));
+ method.setMaxStack();
+ method.setMaxLocals();
+ cg.addMethod(method.getMethod());
+ il.dispose();
+ cg.getJavaClass().dump(out);
+ }
+}
diff --git a/src/test/java/org/apache/bcel/visitors/CountingVisitor.java b/src/test/java/org/apache/bcel/visitors/CountingVisitor.java
index 8a35038598..3522df260f 100644
--- a/src/test/java/org/apache/bcel/visitors/CountingVisitor.java
+++ b/src/test/java/org/apache/bcel/visitors/CountingVisitor.java
@@ -72,6 +72,7 @@
import org.apache.bcel.classfile.SourceFile;
import org.apache.bcel.classfile.StackMap;
import org.apache.bcel.classfile.StackMapEntry;
+import org.apache.bcel.classfile.StackMapType;
import org.apache.bcel.classfile.Synthetic;
import org.apache.bcel.classfile.Unknown;
import org.apache.bcel.classfile.Visitor;
@@ -84,6 +85,8 @@ public class CountingVisitor implements Visitor {
public int stackMapEntryCount;
+ public int stackMapTypeCount;
+
public int stackMapCount;
public int sourceFileCount;
@@ -497,6 +500,14 @@ public void visitStackMapEntry(final StackMapEntry obj) {
stackMapEntryCount++;
}
+ /**
+ * @since 6.8.0
+ */
+ @Override
+ public void visitStackMapType(final StackMapType obj) {
+ stackMapTypeCount++;
+ }
+
@Override
public void visitSynthetic(final Synthetic obj) {
syntheticCount++;
diff --git a/src/test/resources/StackMapExample.class b/src/test/resources/StackMapExample.class
new file mode 100644
index 0000000000000000000000000000000000000000..62066fd675e453d5ac4f2edbe1ca4d75277e1fae
GIT binary patch
literal 790
zcmZuv%Wl&^6g?9=aq74)Cn>KKS{@}2XaKQGi-dTkQVK{xMS|7D86_@u92^J1Z?NMF
zSg@jtAhF;B_#+k|j-8Ye#7N^ibMBpU?i|neUthlgxQ&}87I4qmjF?si5|D4l3uMg5>lc3-*!fwl6>)}eeO>z*9+
z>g_0W2faq3F2f%A^8ZN-EFOy_;s&+^%yuvi9re(SJ1iXMXH9I!5*AG4SZm=b$^z-8
z^1Q%81yutz3)gU6AeVp}&x6qG8rZf_#|>KW51qiuNzYF@hsufOpy@RPvVA$~PhF&?
zdvsX69!rncDwhAc^^~Dec`;A&ZWJk>KO-2Ey*RCRgZfii6j4D*pWfz^M&@AwV;C2C
z^mk6^kG=XPvV0Tq&_M5y)m64%yjy^Iw=*RjgOAeoIk
zGcn0~p3)ebRqa+QwOgAY^@&@oa|(T{e8gziY;6Ml1Jc@VDanFQl6lT}6poO#GZPpe
wp~Zb@NgpFx|A~@;Q^G9#;0b}#L{m8P8zR%Bi~s-t
literal 0
HcmV?d00001
diff --git a/src/test/resources/StackMapExample.java b/src/test/resources/StackMapExample.java
new file mode 100644
index 0000000000..f4fc316825
--- /dev/null
+++ b/src/test/resources/StackMapExample.java
@@ -0,0 +1,18 @@
+/*
+ * Example to check if BCELifier generates the stack map table
+ * so that the generated class passes the Java verifier checks.
+ */
+public abstract class StackMapExample {
+
+ protected abstract void someAbstractMethod();
+
+ public static void main(final String[] args) {
+ switch (args[0]) {
+ case "Hello":
+ System.out.println("Hello World");
+ break;
+ default:
+ break;
+ }
+ }
+}
diff --git a/src/test/resources/StackMapExample2.class b/src/test/resources/StackMapExample2.class
new file mode 100644
index 0000000000000000000000000000000000000000..c449a193599ace4d842693903df20ef1a6fb65e3
GIT binary patch
literal 673
zcmZuvT~8W86g|T(EG%0;Kv1w+zXePrA$`O6(zNLVwM|f)=+l4`9G%_8bus!=eDg2p
z113KB1Nx(kcNS^EbRX`_J@=k-XU@)_m#1d{pRr{liPt@1>XkQO}`hk
z#W$&sk{cF>)3)^h2PxPL@$W(@-@=N6RjgT9cd&s?hIE84{q_TOVxi=qj0(fldntnc
zo%UzzOtix>XmA0tOgA(x&dp^gTyog&kyvifFa7E-@**Tb!Cmqz
z8_gYu8LX~uQe@=Vpuaw185aFx{l&nv1r*biRcU3k#w(9t_fgrQn210!nD)+~0TY;{
zEQKjd6QaonFrr$q@@(EApNUnBS|7$O(ho2*@jen-(I5p7+n{I?H%^bt8c{AHgDll%
OqFz=Y$sBEC$iD)qmXRU=
literal 0
HcmV?d00001
diff --git a/src/test/resources/StackMapExample2.java b/src/test/resources/StackMapExample2.java
new file mode 100644
index 0000000000..24598d3cee
--- /dev/null
+++ b/src/test/resources/StackMapExample2.java
@@ -0,0 +1,12 @@
+/*
+ * Another version of StackMapExample using 2 types of locals String and int
+ * instead of just String.
+ */
+public class StackMapExample2 {
+
+ public static void main(String[] args) {
+ if (args.length == 1 && "Hello".equals(args[0])) {
+ System.out.println("Hello World");
+ }
+ }
+}
diff --git a/src/test/resources/com/foo/Foo.class b/src/test/resources/com/foo/Foo.class
new file mode 100644
index 0000000000000000000000000000000000000000..f405e5fe2098b6c4f70e417eb7197d98fa8858d9
GIT binary patch
literal 770
zcmYjO-EI;=7(D|E3tL(!BCS?!)v7?zy{I=0YN9ob7+Oe*T(lQvfPpSucA91ByZ8=X
zXrj@WXuS3Xd>iB0g`{LN-`{?7zVn^=^Y6zm0MGH*LJV;eMg|Ea1#%;KDQ#DJL%Z1>
zsa_zEeCBvg@IoM7DtFRIA#K9SUmWQ~LlRdA;JE$Pd#3Y5i9?72W={mU!9F-bZi#gtJ`Xu9|E&v_79+)E3%~
z1K;t6iPA0YT=}89bxM5L>o7p5bu7VF9V42kwW-Z2X`a*u|
zH|`x)zClzrzQU}=jrM2OW6093uqVmSg2_CE9Bai0w}4gTnGqqv7r4eaLAmGzi`Qwx
zL3=Qw3)yH;qw)pjj$yPv^4Dxel8s4T3$Zhd!ATKz&I(^*4pSsd$k!_1e*Qt?J9a)X
Q3o(k3T|<>V#JUCi2Ui=Jr2qf`
literal 0
HcmV?d00001
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammar/java/JavaLanguageParser$ClassBlockContext.class b/src/test/resources/com/puppycrawl/tools/checkstyle/grammar/java/JavaLanguageParser$ClassBlockContext.class
new file mode 100644
index 0000000000000000000000000000000000000000..c5da924abfebdf3de76ed1fa0dbc5d639a84429f
GIT binary patch
literal 2624
zcmcImTUQ%Z6#h;UG9d|trbv<2OBFR2=va!SHj#UgUroM3tM
z#s8pd`5*M9ULIWd>Z?D+XI<_|rZ@_8Ef)BY*=P2d^X+f%voHDWub+PbFojPI+@q^HF*O|NCo6KcWbt(Isp
ztY>o-TQLh|i
z;o5Xsj+UyJt8|jZr9?5;w)cdsDR#y|cb8%8JXj1v|4y94=8NQ+I0sItU|Gd!qS05=
z+}>a1%^(ANYfjzcx~(WhS4-A|lhmir<9lEyN7fjUHQ83SSaSUQzkafIZu?8bV0x%P0}c$WZvAwpEko)hb)h%ft~jpyQZ|%59XiGG8QrDZJVU1`T@r+6$$jBbiDb)Xojk2C
zMYDcSNZ7J@xTIu*+Ha@W{)q@f{jz#eXr7#2==rnT>3=%~m1CFauH)_~-|_n|D>gq|
zolbmegGr6!#%w4!nIWO8b9V(Q)v)vJ8a5aP=B3mvt$4HRcni14ffR89dO&{$&`-|+dYeHUQIfA@mXENqn$NK4
zb3~57#-cInJKBiAcO_1r$CG`?&^k?PI)H2R1FeT}Jpd~OV3`1HV3xpQW3iJ+{UM~x
zG14$b0;FZ486)(;4pKG$1A6j>=ZKH@#H{a0A7(Ys!5ShReIH=?s~fmUXbi96b=vct
z{W3t!c2Ntz!uT4Q!V!%8Pe?>C9w(*+TKCf0=(3LCZ93Tt_9wv^Sm}f#Nr3U>HQY=N
zhKy&Ajc4%&-Xznv=x8@wzUD2`jFKjTcLtJvR?)jpYlvL+?|{HQ$*d-RM9mL8NPC5z
kBeX|TAALk3Npg^6isY*#-=+Ns-h)NbzoJEw*^VyyH%Eo?wEzGB
literal 0
HcmV?d00001
diff --git a/src/test/resources/issue369/Test.class b/src/test/resources/issue369/Test.class
new file mode 100644
index 0000000000000000000000000000000000000000..78c100c0c755c5071720eed291bd2db4f9e0f23a
GIT binary patch
literal 283
zcmW-a%}T>i5QV?n-1IhS($-x?1QC?BNV5ZOeNr!yQd3BpK0%+t7qBk7
z5?tushY}~wz#Puc%>4X*egQ*TJ`TR2X$Tbc%QQ<@R|?&`?N0@+mrqvFzDqMZE?*Lx
zPvT@DivPGQ^O?O#E8`*v*+j`ncJC2POm@Z
zh?;z_N=a*6nRQ{gpeuMf_&{xx+7i6cz2D-VeUA@b(YuZr>5cZ@9dUPZMdK67M#$bj
kDvYp!sEDWKs*$cTAq~2C?9=3sfMZ&m(3X!4$=2}x0MJA&00000
literal 0
HcmV?d00001
diff --git a/src/test/resources/jira368/Test.class b/src/test/resources/jira368/Test.class
new file mode 100644
index 0000000000000000000000000000000000000000..2f5ce45c5ca7d8d911ca7f79277113f0de35e725
GIT binary patch
literal 162
zcmX^0Z`VEs1_nb0E=C64%;MtGRAVy>y^z%65_SegMh1bb#Ii*FoW#6zegCAa)MTJ2
zGa~~hNL~*l#mK-|%*ep3p&7==z~Y>rlFG=y6`WsMl$`38nUl((z`(@70yLh10jP
z6O(G&+Y$_pr#FNjQeq>;klN(iJXhmtJy+fdv~c6-q>5f$GxU@~r}T0!d}5@meZk#)
z65Z%YpbKXix=sj)qmLo}&ScaSfn*veVTtE!o1&ugW{v@zbI^}LhVD%E-;gBQk#Jz)
z0z+$)EW>Ub7a8p0Qh9l9X?}sB?Jw$+xP*}ehH;sK3Kd!>5okCIp)$sOCPAR13>`;_
z&xGbxt~s$}x!VzXHOvUx2r#fMqeRI0K^kqGwCV)I;Nhe$$dHDkc2+8V>?NucLiIRcc-!)jG{dAAliImg|b^x=-m&
z*{k~%u_z5z|I514(iJN*kOV%bl&5+4(lJh)wNU@`Q)p*IA`ua#L&TEh0cj%?K_enI
z8aY7nGieO7B$Ev*+QOU;v(;wCbTh;0?ASx^n|+)&Sr+C1#vSqp
Km=16^K>KeIuKT(G
literal 0
HcmV?d00001
diff --git a/src/test/resources/ossfuzz/issue51980/Test.class b/src/test/resources/ossfuzz/issue51980/Test.classx
similarity index 100%
rename from src/test/resources/ossfuzz/issue51980/Test.class
rename to src/test/resources/ossfuzz/issue51980/Test.classx
diff --git a/src/test/resources/ossfuzz/issue51989/Test.class b/src/test/resources/ossfuzz/issue51989/Test.classx
similarity index 100%
rename from src/test/resources/ossfuzz/issue51989/Test.class
rename to src/test/resources/ossfuzz/issue51989/Test.classx
diff --git a/src/test/resources/ossfuzz/issue52168/Test.class b/src/test/resources/ossfuzz/issue52168/Test.classx
similarity index 100%
rename from src/test/resources/ossfuzz/issue52168/Test.class
rename to src/test/resources/ossfuzz/issue52168/Test.classx
diff --git a/src/test/resources/ossfuzz/issue53543/Test.class b/src/test/resources/ossfuzz/issue53543/Test.classx
similarity index 100%
rename from src/test/resources/ossfuzz/issue53543/Test.class
rename to src/test/resources/ossfuzz/issue53543/Test.classx
diff --git a/src/test/resources/ossfuzz/issue53544a/Test.class b/src/test/resources/ossfuzz/issue53544a/Test.classx
similarity index 100%
rename from src/test/resources/ossfuzz/issue53544a/Test.class
rename to src/test/resources/ossfuzz/issue53544a/Test.classx
diff --git a/src/test/resources/ossfuzz/issue53620/Test.class b/src/test/resources/ossfuzz/issue53620/Test.classx
similarity index 100%
rename from src/test/resources/ossfuzz/issue53620/Test.class
rename to src/test/resources/ossfuzz/issue53620/Test.classx
diff --git a/src/test/resources/ossfuzz/issue53676/Test.classx b/src/test/resources/ossfuzz/issue53676/Test.classx
new file mode 100644
index 0000000000000000000000000000000000000000..c0ca8577272b9cb18f7a3911962f185c221ce9f5
GIT binary patch
literal 26
acmX^0Z`ZyUW_1PzMutWph62V!1_l6Q^#rT{
literal 0
HcmV?d00001
diff --git a/src/test/resources/ossfuzz/issue54119/Test.classx b/src/test/resources/ossfuzz/issue54119/Test.classx
new file mode 100644
index 0000000000000000000000000000000000000000..4b405c315a3166a2e6dae06328e9cb1d71574710
GIT binary patch
literal 24
VcmX^0Z`VFf#;yMu7_}LY0RU=61uFmm
literal 0
HcmV?d00001
diff --git a/src/test/resources/ossfuzz/issue54254/Test.classx b/src/test/resources/ossfuzz/issue54254/Test.classx
new file mode 100644
index 0000000000000000000000000000000000000000..275741ee047126398d5d09f3da0be10e7a5c0f43
GIT binary patch
literal 42
ecmX^0Z`VErAYfo)S5SZ;RuCTy7#LU?-~a%^?*+yH
literal 0
HcmV?d00001
diff --git a/src/test/resources/ossfuzz/readme.txt b/src/test/resources/ossfuzz/readme.txt
new file mode 100644
index 0000000000..76c8a013ed
--- /dev/null
+++ b/src/test/resources/ossfuzz/readme.txt
@@ -0,0 +1,19 @@
+
+Class names here use non-".class" suffix so that Maven plugins like surefire do not try to read the file and fail the build.
From 7a0d70b89b90b9e8299b68df9f65de51f51015f8 Mon Sep 17 00:00:00 2001
From: Mark Roberts
Date: Wed, 7 Feb 2024 21:17:47 -0800
Subject: [PATCH 2/9] DoNothingChecker => DoNothingProcessor
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index d74f67a921..9492dcd4aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -459,8 +459,8 @@
succeedingTypecheckers
org.checkerframework.checker.interning.InterningChecker
- org.checkerframework.common.util.report.DoNothingChecker
- org.checkerframework.common.util.report.DoNothingChecker
+ org.checkerframework.common.util.report.DoNothingProcessor
+ org.checkerframework.common.util.report.DoNothingProcessor
org.checkerframework.checker.signedness.SignednessChecker
org.checkerframework.checker.resourceleak.ResourceLeakChecker
From 4af1b392a9f582813fd46a6872901193d085f23d Mon Sep 17 00:00:00 2001
From: Mark Roberts
Date: Wed, 7 Feb 2024 21:18:25 -0800
Subject: [PATCH 3/9] fix/suppress some new mustcall warnings
---
.../java/org/apache/bcel/util/ClassPath.java | 31 +++++++++++++------
.../apache/bcel/util/ModularRuntimeImage.java | 16 +++++++---
.../apache/bcel/util/SyntheticRepository.java | 1 +
3 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/bcel/util/ClassPath.java b/src/main/java/org/apache/bcel/util/ClassPath.java
index 9bb27c8936..155f226bfa 100644
--- a/src/main/java/org/apache/bcel/util/ClassPath.java
+++ b/src/main/java/org/apache/bcel/util/ClassPath.java
@@ -44,6 +44,7 @@
import org.apache.bcel.classfile.Utility;
import org.checkerframework.checker.calledmethods.qual.EnsuresCalledMethods;
+import org.checkerframework.checker.mustcall.qual.MustCall;
import org.checkerframework.checker.mustcall.qual.Owning;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.qual.Pure;
@@ -62,6 +63,7 @@ private abstract static class AbstractPathEntry implements Closeable {
abstract InputStream getResourceAsStream(String name);
}
+ @MustCall("close")
private abstract static class AbstractZip extends AbstractPathEntry {
private final ZipFile zipFile;
@@ -361,25 +363,35 @@ private static final class JrtModules extends AbstractPathEntry {
private final @Owning ModularRuntimeImage modularRuntimeImage;
private final @Owning JrtModule[] modules;
+ @SuppressWarnings("mustcall:type.argument") // mustcall doesn't support arrays yet
public JrtModules(final String path) throws IOException {
this.modularRuntimeImage = new ModularRuntimeImage();
- this.modules = modularRuntimeImage.list(path).stream().map(JrtModule::new).toArray(JrtModule[]::new);
+ try {
+ this.modules = modularRuntimeImage.list(path).stream().map(JrtModule::new).toArray(JrtModule[]::new);
+ } finally {
+ if (modularRuntimeImage != null) {
+ modularRuntimeImage.close();
+ }
+ }
}
@Override
@SuppressWarnings({"builder:contracts.postcondition", // Called on each *element* of `modules`
- "builder:destructor.exceptional.postcondition" // might not close everything
+ "builder:contracts.exceptional.postcondition" // might not close everything
})
@EnsuresCalledMethods(value = {"modules", "modularRuntimeImage"}, methods = "close")
public void close() throws IOException {
- if (modules != null) {
- // don't use a for each loop to avoid creating an iterator for the GC to collect.
- for (final JrtModule module : modules) {
- module.close();
+ try {
+ if (modules != null) {
+ // don't use a for each loop to avoid creating an iterator for the GC to collect.
+ for (final JrtModule module : modules) {
+ module.close();
+ }
+ }
+ } finally {
+ if (modularRuntimeImage != null) {
+ modularRuntimeImage.close();
}
- }
- if (modularRuntimeImage != null) {
- modularRuntimeImage.close();
}
}
@@ -529,6 +541,7 @@ private static void getPathComponents(final String path, final List list
private final @Nullable ClassPath parent;
+ @SuppressWarnings("mustcall:type.argument")
private final @Owning List paths;
/**
diff --git a/src/main/java/org/apache/bcel/util/ModularRuntimeImage.java b/src/main/java/org/apache/bcel/util/ModularRuntimeImage.java
index c0d64bfca9..8e9314da63 100644
--- a/src/main/java/org/apache/bcel/util/ModularRuntimeImage.java
+++ b/src/main/java/org/apache/bcel/util/ModularRuntimeImage.java
@@ -36,6 +36,7 @@
import org.checkerframework.checker.calledmethods.qual.EnsuresCalledMethods;
import org.checkerframework.checker.mustcall.qual.Owning;
+import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.qual.Pure;
/**
@@ -48,13 +49,12 @@ public class ModularRuntimeImage implements Closeable {
static final String MODULES_PATH = File.separator + "modules";
static final String PACKAGES_PATH = File.separator + "packages";
- private final @Owning URLClassLoader classLoader;
+ private final @Owning @Nullable URLClassLoader classLoader;
private final @Owning FileSystem fileSystem;
/**
* Constructs a default instance.
*/
- @SuppressWarnings("resource") // See #close()
public ModularRuntimeImage() {
this(null, FileSystems.getFileSystem(URI.create("jrt:/")));
}
@@ -71,16 +71,22 @@ public ModularRuntimeImage(final String javaHome) throws IOException {
final Path jrePath = Paths.get(javaHome);
final Path jrtFsPath = jrePath.resolve("lib").resolve("jrt-fs.jar");
this.classLoader = URLClassLoader.newInstance(new URL[] {jrtFsPath.toUri().toURL()});
- this.fileSystem = FileSystems.newFileSystem(URI.create("jrt:/"), emptyMap, classLoader);
+ try {
+ this.fileSystem = FileSystems.newFileSystem(URI.create("jrt:/"), emptyMap, classLoader);
+ } finally {
+ if (classLoader != null) {
+ classLoader.close();
+ }
+ }
}
- private ModularRuntimeImage(final URLClassLoader cl, final FileSystem fs) {
+ private ModularRuntimeImage(final @Nullable URLClassLoader cl, final FileSystem fs) {
this.classLoader = cl;
this.fileSystem = fs;
}
- @SuppressWarnings("builder:contracts.postcondition") // I think it's satisfied. Checker bug?
@Override
+ @SuppressWarnings("builder:contracts.postcondition") // some non-null fileSytems cannot be closed
@EnsuresCalledMethods(value={"classLoader", "fileSystem"}, methods="close")
public void close() throws IOException {
try {
diff --git a/src/main/java/org/apache/bcel/util/SyntheticRepository.java b/src/main/java/org/apache/bcel/util/SyntheticRepository.java
index c046cb4eb3..26e90ba853 100644
--- a/src/main/java/org/apache/bcel/util/SyntheticRepository.java
+++ b/src/main/java/org/apache/bcel/util/SyntheticRepository.java
@@ -32,6 +32,7 @@
*/
public class SyntheticRepository extends MemorySensitiveClassPathRepository {
+ @SuppressWarnings("mustcall:type.argument")
private static final Map MAP = new HashMap<>(); // CLASSPATH X REPOSITORY
public static SyntheticRepository getInstance() {
From 485cad2b7b2e60885b088eb9866cd03848bf4388 Mon Sep 17 00:00:00 2001
From: Mark Roberts
Date: Wed, 7 Feb 2024 21:23:28 -0800
Subject: [PATCH 4/9] correct processor path
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9492dcd4aa..bbd7cf520a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -459,8 +459,8 @@
succeedingTypecheckers
org.checkerframework.checker.interning.InterningChecker
- org.checkerframework.common.util.report.DoNothingProcessor
- org.checkerframework.common.util.report.DoNothingProcessor
+ org.checkerframework.common.util.debug.DoNothingProcessor
+ org.checkerframework.common.util.debug.DoNothingProcessor
org.checkerframework.checker.signedness.SignednessChecker
org.checkerframework.checker.resourceleak.ResourceLeakChecker
From f161f8fa19474d025a69ed51dfdfd2245c9e22d0 Mon Sep 17 00:00:00 2001
From: Mark Roberts
Date: Wed, 7 Feb 2024 21:43:07 -0800
Subject: [PATCH 5/9] fix interning of ==
---
src/main/java/org/apache/bcel/classfile/Constant.java | 2 +-
src/main/java/org/apache/bcel/classfile/Field.java | 2 +-
src/main/java/org/apache/bcel/classfile/JavaClass.java | 2 +-
src/main/java/org/apache/bcel/classfile/Method.java | 2 +-
src/main/java/org/apache/bcel/generic/ClassGen.java | 2 +-
src/main/java/org/apache/bcel/generic/FieldGen.java | 2 +-
src/main/java/org/apache/bcel/generic/MethodGen.java | 2 +-
src/main/java/org/apache/bcel/generic/Select.java | 2 +-
.../apache/bcel/verifier/structurals/InstConstraintVisitor.java | 2 +-
9 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/apache/bcel/classfile/Constant.java b/src/main/java/org/apache/bcel/classfile/Constant.java
index 72044d3da1..70c4f2e2e1 100644
--- a/src/main/java/org/apache/bcel/classfile/Constant.java
+++ b/src/main/java/org/apache/bcel/classfile/Constant.java
@@ -37,7 +37,7 @@ public abstract class Constant implements Cloneable, Node {
@Override
public boolean equals(final Constant a, final Constant b) {
- return a == b || a != null && b != null && Objects.equals(a.toString(), b.toString());
+ return a.equals(b) || a != null && b != null && Objects.equals(a.toString(), b.toString());
}
@Override
diff --git a/src/main/java/org/apache/bcel/classfile/Field.java b/src/main/java/org/apache/bcel/classfile/Field.java
index a3c1db9643..45f86b0b6c 100644
--- a/src/main/java/org/apache/bcel/classfile/Field.java
+++ b/src/main/java/org/apache/bcel/classfile/Field.java
@@ -47,7 +47,7 @@ public final class Field extends FieldOrMethod {
@Override
public boolean equals(final Field a, final Field b) {
- return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
+ return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
diff --git a/src/main/java/org/apache/bcel/classfile/JavaClass.java b/src/main/java/org/apache/bcel/classfile/JavaClass.java
index 398bca30b1..9a798a1899 100644
--- a/src/main/java/org/apache/bcel/classfile/JavaClass.java
+++ b/src/main/java/org/apache/bcel/classfile/JavaClass.java
@@ -79,7 +79,7 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
@Override
public boolean equals(final JavaClass a, final JavaClass b) {
- return a == b || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
+ return a.equals(b) || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
}
@Override
diff --git a/src/main/java/org/apache/bcel/classfile/Method.java b/src/main/java/org/apache/bcel/classfile/Method.java
index 126bbb9fb3..ef6a06d2a7 100644
--- a/src/main/java/org/apache/bcel/classfile/Method.java
+++ b/src/main/java/org/apache/bcel/classfile/Method.java
@@ -46,7 +46,7 @@ public final class Method extends FieldOrMethod {
@Override
public boolean equals(final Method a, final Method b) {
- return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
+ return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
diff --git a/src/main/java/org/apache/bcel/generic/ClassGen.java b/src/main/java/org/apache/bcel/generic/ClassGen.java
index 7709132bd1..809d94e277 100644
--- a/src/main/java/org/apache/bcel/generic/ClassGen.java
+++ b/src/main/java/org/apache/bcel/generic/ClassGen.java
@@ -55,7 +55,7 @@ public class ClassGen extends AccessFlags implements Cloneable {
@Override
public boolean equals(final ClassGen a, final ClassGen b) {
- return a == b || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
+ return a.equals(b) || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
}
@Override
diff --git a/src/main/java/org/apache/bcel/generic/FieldGen.java b/src/main/java/org/apache/bcel/generic/FieldGen.java
index bd8f20963b..ab615f6248 100644
--- a/src/main/java/org/apache/bcel/generic/FieldGen.java
+++ b/src/main/java/org/apache/bcel/generic/FieldGen.java
@@ -50,7 +50,7 @@ public class FieldGen extends FieldGenOrMethodGen {
@Override
public boolean equals(final FieldGen a, final FieldGen b) {
- return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
+ return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
diff --git a/src/main/java/org/apache/bcel/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java
index 5a786a6f95..e9412b6cc8 100644
--- a/src/main/java/org/apache/bcel/generic/MethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/MethodGen.java
@@ -112,7 +112,7 @@ static final class BranchTarget {
@Override
public boolean equals(final FieldGenOrMethodGen a, final FieldGenOrMethodGen b) {
- return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
+ return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
diff --git a/src/main/java/org/apache/bcel/generic/Select.java b/src/main/java/org/apache/bcel/generic/Select.java
index 832568f02a..ea3914c004 100644
--- a/src/main/java/org/apache/bcel/generic/Select.java
+++ b/src/main/java/org/apache/bcel/generic/Select.java
@@ -324,7 +324,7 @@ public String toString(final boolean verbose) {
for (int i = 0; i < match_length; i++) {
String s = "null";
if (targets[i] != null) {
- if (targets[i].getInstruction() == this) {
+ if (targets[i].getInstruction().equals(this)) {
s = "";
} else {
s = targets[i].getInstruction().toString();
diff --git a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
index 5156a0ebef..dcd99554a8 100644
--- a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
+++ b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
@@ -1777,7 +1777,7 @@ public void visitINVOKEVIRTUAL(final INVOKEVIRTUAL o) {
final String theClass = o.getClassName(cpg);
- if (objref != GENERIC_ARRAY && !Repository.instanceOf(objRefClassName, theClass)) {
+ if (!objref.equals(GENERIC_ARRAY) && !Repository.instanceOf(objRefClassName, theClass)) {
constraintViolated(o, "The 'objref' item '" + objref + "' does not implement '" + theClass + "' as expected.");
}
} catch (final ClassNotFoundException e) {
From bab0658df55d6cc81f8338f9227e47e327a4cc6d Mon Sep 17 00:00:00 2001
From: Mark Roberts
Date: Thu, 8 Feb 2024 11:32:37 -0800
Subject: [PATCH 6/9] remove unneeded suppressions
---
src/main/java/org/apache/bcel/Const.java | 2 --
src/main/java/org/apache/bcel/classfile/ConstantPool.java | 2 --
src/main/java/org/apache/bcel/classfile/LineNumber.java | 1 -
src/main/java/org/apache/bcel/classfile/Signature.java | 1 -
src/main/java/org/apache/bcel/classfile/SimpleElementValue.java | 2 --
src/main/java/org/apache/bcel/classfile/Utility.java | 1 -
src/main/java/org/apache/bcel/generic/InstructionFactory.java | 1 -
7 files changed, 10 deletions(-)
diff --git a/src/main/java/org/apache/bcel/Const.java b/src/main/java/org/apache/bcel/Const.java
index 4fca1a4fee..5decdc0597 100644
--- a/src/main/java/org/apache/bcel/Const.java
+++ b/src/main/java/org/apache/bcel/Const.java
@@ -549,7 +549,6 @@ public final class Const {
*
* @see #ACC_PUBLIC
*/
- @SuppressWarnings("value:cast.unsafe") // should only be used to mask or test flags
public static final @Unsigned short ACC_MANDATED = (short) 0x8000;
/**
@@ -557,7 +556,6 @@ public final class Const {
*
* @see #ACC_PUBLIC
*/
- @SuppressWarnings("value:cast.unsafe") // should only be used to mask or test flags
public static final @Unsigned short ACC_MODULE = (short) 0x8000;
/**
diff --git a/src/main/java/org/apache/bcel/classfile/ConstantPool.java b/src/main/java/org/apache/bcel/classfile/ConstantPool.java
index 8f69a057f9..daf77f72de 100644
--- a/src/main/java/org/apache/bcel/classfile/ConstantPool.java
+++ b/src/main/java/org/apache/bcel/classfile/ConstantPool.java
@@ -259,7 +259,6 @@ public void dump(final DataOutputStream file) throws IOException {
* @see Constant
* @throws ClassFormatException if index is invalid
*/
- @SuppressWarnings("signedness:return")
public T getConstant(final @NonNegative int index) throws ClassFormatException {
return (T) getConstant(index, Constant.class);
}
@@ -273,7 +272,6 @@ public T getConstant(final @NonNegative int index) throws C
* @see Constant
* @throws ClassFormatException if constant type does not match tag
*/
- @SuppressWarnings("signedness:return")
public T getConstant(final @NonNegative int index, final byte tag) throws ClassFormatException {
return (T) getConstant(index, tag, Constant.class);
}
diff --git a/src/main/java/org/apache/bcel/classfile/LineNumber.java b/src/main/java/org/apache/bcel/classfile/LineNumber.java
index 4d8ab3fb25..02a0c49de8 100644
--- a/src/main/java/org/apache/bcel/classfile/LineNumber.java
+++ b/src/main/java/org/apache/bcel/classfile/LineNumber.java
@@ -103,7 +103,6 @@ public LineNumber copy() {
* @param file Output file stream
* @throws IOException if an I/O Exception occurs in writeShort
*/
- @SuppressWarnings("signedness:argument") // writeShort only writes low 16 bits
public void dump(final DataOutputStream file) throws IOException {
file.writeShort(startPc);
file.writeShort(lineNumber);
diff --git a/src/main/java/org/apache/bcel/classfile/Signature.java b/src/main/java/org/apache/bcel/classfile/Signature.java
index 3605ce182b..176815e494 100644
--- a/src/main/java/org/apache/bcel/classfile/Signature.java
+++ b/src/main/java/org/apache/bcel/classfile/Signature.java
@@ -105,7 +105,6 @@ private static void matchGJIdent(final MyByteArrayInputStream in, final StringBu
}
}
- @SuppressWarnings("signedness:cast.unsafe") // read() in range -1 to 255; we test for eof(-1)
private static void matchIdent(final MyByteArrayInputStream in, final StringBuilder buf) {
int ch;
if ((ch = in.read()) == -1) {
diff --git a/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java b/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java
index 9958a10b18..ee6f10946f 100644
--- a/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java
+++ b/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java
@@ -83,7 +83,6 @@ public byte getValueByte() {
return (byte) super.getConstantPool().getConstantInteger(getIndex()).getBytes();
}
- @SuppressWarnings("signedness:cast.unsafe") // code tests for type char before cast
@Pure
public char getValueChar() {
if (super.getType() != PRIMITIVE_CHAR) {
@@ -172,7 +171,6 @@ public String stringifyValue() {
return Integer.toString(b.getBytes());
case PRIMITIVE_CHAR:
final ConstantInteger ch = cpool.getConstantInteger(getIndex());
- @SuppressWarnings("signedness:cast.unsafe") // code tests for type char before cast
final char chChar = (char) ch.getBytes();
return String.valueOf(chChar);
case PRIMITIVE_BOOLEAN:
diff --git a/src/main/java/org/apache/bcel/classfile/Utility.java b/src/main/java/org/apache/bcel/classfile/Utility.java
index c92b3341a5..d0d15c2f78 100644
--- a/src/main/java/org/apache/bcel/classfile/Utility.java
+++ b/src/main/java/org/apache/bcel/classfile/Utility.java
@@ -87,7 +87,6 @@ public int read() throws IOException {
@Override
public int read(final char[] cbuf, final int off, final int len) throws IOException {
for (int i = 0; i < len; i++) {
- @SuppressWarnings("signedness:cast.unsafe") // result of read() is range x'00' to x'ff'
char temp = (char)read();
cbuf[off + i] = temp;
}
diff --git a/src/main/java/org/apache/bcel/generic/InstructionFactory.java b/src/main/java/org/apache/bcel/generic/InstructionFactory.java
index bdc9ca556e..e7d2e9fc77 100644
--- a/src/main/java/org/apache/bcel/generic/InstructionFactory.java
+++ b/src/main/java/org/apache/bcel/generic/InstructionFactory.java
@@ -530,7 +530,6 @@ public Instruction createCast(final Type srcType, final Type destType) {
} catch (final Exception e) {
throw new IllegalArgumentException("Could not find instruction: " + name, e);
}
- @SuppressWarnings("mustcall:assignment") // reflection
@MustCall Instruction result = i;
return result;
}
From 96a43e831bff259ee9a1e21291680c29772ad7ab Mon Sep 17 00:00:00 2001
From: Mark Roberts
Date: Thu, 8 Feb 2024 11:33:39 -0800
Subject: [PATCH 7/9] clean up signature annotations and suppressions
---
.../java/org/apache/bcel/util/JavaWrapper.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/bcel/util/JavaWrapper.java b/src/main/java/org/apache/bcel/util/JavaWrapper.java
index 895b362440..5e42bf1562 100644
--- a/src/main/java/org/apache/bcel/util/JavaWrapper.java
+++ b/src/main/java/org/apache/bcel/util/JavaWrapper.java
@@ -22,6 +22,7 @@
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.signature.qual.BinaryName;
+import org.checkerframework.checker.signature.qual.ClassGetName;
/**
* Java interpreter replacement, i.e., wrapper that uses its own ClassLoader to modify/generate classes as they're
@@ -45,11 +46,10 @@
*/
public class JavaWrapper {
- @SuppressWarnings({"signature", // if bcel.classloader isn't a @ClassGetName, error is thrown
- "mustcall:return" // reflection
- })
+ @SuppressWarnings("nullness:argument") // it is legal to pass null to isEmpty
private static java.lang.ClassLoader getClassLoader() {
- final String s = System.getProperty("bcel.classloader");
+ @SuppressWarnings("signature:assignment") // we assume system property is legal className
+ final @ClassGetName String s = System.getProperty("bcel.classloader");
if (StringUtils.isEmpty(s)) {
throw new IllegalStateException("The property 'bcel.classloader' must be defined");
}
@@ -71,7 +71,8 @@ public static void main(final String[] argv) throws Exception {
System.out.println("Missing class name.");
return;
}
- final String className = argv[0];
+ @SuppressWarnings("signature:assignment") // we assume user passes legal argument for className
+ final @BinaryName String className = argv[0];
final String[] newArgv = new String[argv.length - 1];
System.arraycopy(argv, 1, newArgv, 0, newArgv.length);
new JavaWrapper().runMain(className, newArgv);
@@ -112,7 +113,8 @@ public void runMain(final @BinaryName String className, final String[] argv ) th
return;
}
try {
- method.invoke(null, (Object[]) argv);
+ @SuppressWarnings("nullness:argument") // method is static, therefore first arg can be null (we ignore result)
+ Object result = method.invoke(null, (Object[]) argv);
} catch (final Exception ex) {
ex.printStackTrace();
}
From 03a20d46dd211141869c2d15fab7d87745b9fee5 Mon Sep 17 00:00:00 2001
From: Mark Roberts
Date: Thu, 8 Feb 2024 11:34:24 -0800
Subject: [PATCH 8/9] correct interning changes
---
src/main/java/org/apache/bcel/classfile/Constant.java | 3 ++-
src/main/java/org/apache/bcel/classfile/Field.java | 3 ++-
src/main/java/org/apache/bcel/classfile/JavaClass.java | 3 ++-
src/main/java/org/apache/bcel/classfile/Method.java | 3 ++-
src/main/java/org/apache/bcel/generic/ClassGen.java | 3 ++-
src/main/java/org/apache/bcel/generic/FieldGen.java | 3 ++-
src/main/java/org/apache/bcel/generic/MethodGen.java | 3 ++-
7 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/bcel/classfile/Constant.java b/src/main/java/org/apache/bcel/classfile/Constant.java
index 70c4f2e2e1..1d0389ef7e 100644
--- a/src/main/java/org/apache/bcel/classfile/Constant.java
+++ b/src/main/java/org/apache/bcel/classfile/Constant.java
@@ -36,8 +36,9 @@ public abstract class Constant implements Cloneable, Node {
private static BCELComparator bcelComparator = new BCELComparator() {
@Override
+ @SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final Constant a, final Constant b) {
- return a.equals(b) || a != null && b != null && Objects.equals(a.toString(), b.toString());
+ return a == b || a != null && b != null && Objects.equals(a.toString(), b.toString());
}
@Override
diff --git a/src/main/java/org/apache/bcel/classfile/Field.java b/src/main/java/org/apache/bcel/classfile/Field.java
index 45f86b0b6c..4aceaa6a2a 100644
--- a/src/main/java/org/apache/bcel/classfile/Field.java
+++ b/src/main/java/org/apache/bcel/classfile/Field.java
@@ -46,8 +46,9 @@ public final class Field extends FieldOrMethod {
private static BCELComparator bcelComparator = new BCELComparator() {
@Override
+ @SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final Field a, final Field b) {
- return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
+ return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
diff --git a/src/main/java/org/apache/bcel/classfile/JavaClass.java b/src/main/java/org/apache/bcel/classfile/JavaClass.java
index 9a798a1899..ea8aea57af 100644
--- a/src/main/java/org/apache/bcel/classfile/JavaClass.java
+++ b/src/main/java/org/apache/bcel/classfile/JavaClass.java
@@ -78,8 +78,9 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
private static BCELComparator bcelComparator = new BCELComparator() {
@Override
+ @SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final JavaClass a, final JavaClass b) {
- return a.equals(b) || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
+ return a == b || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
}
@Override
diff --git a/src/main/java/org/apache/bcel/classfile/Method.java b/src/main/java/org/apache/bcel/classfile/Method.java
index ef6a06d2a7..a0544236fb 100644
--- a/src/main/java/org/apache/bcel/classfile/Method.java
+++ b/src/main/java/org/apache/bcel/classfile/Method.java
@@ -45,8 +45,9 @@ public final class Method extends FieldOrMethod {
private static BCELComparator bcelComparator = new BCELComparator() {
@Override
+ @SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final Method a, final Method b) {
- return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
+ return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
diff --git a/src/main/java/org/apache/bcel/generic/ClassGen.java b/src/main/java/org/apache/bcel/generic/ClassGen.java
index 809d94e277..004560255f 100644
--- a/src/main/java/org/apache/bcel/generic/ClassGen.java
+++ b/src/main/java/org/apache/bcel/generic/ClassGen.java
@@ -54,8 +54,9 @@ public class ClassGen extends AccessFlags implements Cloneable {
private static BCELComparator bcelComparator = new BCELComparator() {
@Override
+ @SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final ClassGen a, final ClassGen b) {
- return a.equals(b) || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
+ return a == b || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
}
@Override
diff --git a/src/main/java/org/apache/bcel/generic/FieldGen.java b/src/main/java/org/apache/bcel/generic/FieldGen.java
index ab615f6248..77168d0228 100644
--- a/src/main/java/org/apache/bcel/generic/FieldGen.java
+++ b/src/main/java/org/apache/bcel/generic/FieldGen.java
@@ -49,8 +49,9 @@ public class FieldGen extends FieldGenOrMethodGen {
private static BCELComparator bcelComparator = new BCELComparator() {
@Override
+ @SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final FieldGen a, final FieldGen b) {
- return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
+ return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
diff --git a/src/main/java/org/apache/bcel/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java
index e9412b6cc8..e2e2b7c879 100644
--- a/src/main/java/org/apache/bcel/generic/MethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/MethodGen.java
@@ -111,8 +111,9 @@ static final class BranchTarget {
private static BCELComparator bcelComparator = new BCELComparator() {
@Override
+ @SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final FieldGenOrMethodGen a, final FieldGenOrMethodGen b) {
- return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
+ return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}
@Override
From fa12e3d1e483ed38903c7a8ac5ba3db09f6770f8 Mon Sep 17 00:00:00 2001
From: Mark Roberts
Date: Thu, 8 Feb 2024 13:15:05 -0800
Subject: [PATCH 9/9] turn off the moditect plugin
---
.github/workflows/maven.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index e4b3e131be..7e0cdaeba8 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -36,6 +36,6 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: compile with passing checkers
- run: mvn -V apache-rat:check -PsucceedingTypecheckers compile --file pom.xml
+ run: mvn -V apache-rat:check -PsucceedingTypecheckers compile --file pom.xml -Dmoditect.skip=true
- name: Build with Maven
- run: mvn -V apache-rat:check clean package --file pom.xml
+ run: mvn -V apache-rat:check clean package --file pom.xml -Dmoditect.skip=true