Skip to content

Commit

Permalink
Fix Spotbugs [ERROR] Class org.apache.bcel.util.ClassVector defines
Browse files Browse the repository at this point in the history
non-transient non-serializable instance field vec
[org.apache.bcel.util.ClassVector] In ClassVector.java SE_BAD_FIELD
  • Loading branch information
garydgregory committed Dec 3, 2023
1 parent 86de369 commit 2df0926
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The <action> type attribute can be add,update,fix,remove.
-->

<body>
<release version="6.8.0" date="TBD" description="Maintenance and bug fix release.">
<release version="6.8.0" date="2023-12-03" description="Maintenance and bug fix release.">
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use InvalidMethodSignatureException extending ClassFormatException.</action>
<action type="add" dev="ggregory" due-to="nbauma109">Increase code coverage in Class2HTMLTestCase with new test input Java4Example #186.</action>
Expand All @@ -75,6 +75,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add Const.MAJOR_21.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add Const.MINOR_21.</action>
<action type="add" dev="ggregory" due-to="nbauma109, Gary Gregory, Mark Roberts">[Bcelifier] stackmap support to pass JDK verifier #177.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">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.</action>
<!-- FIX -->
<action type="fix" dev="markt" due-to="OSS-Fuzz">When parsing an class with an invalid constant reference, ensure ClassParser.parse() throws ClassFormatException, not NullPointerException.</action>
<action type="fix" dev="markt" due-to="OSS-Fuzz">Ensure that references to a constant pool entry with index zero trigger a ClassFormatException, not a NullPointerException.</action>
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/apache/bcel/util/ClassVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
public class ClassVector implements Serializable {

private static final long serialVersionUID = 5600397075672780806L;

@Deprecated
protected List<JavaClass> vec = new ArrayList<>();
protected transient List<JavaClass> vec = new ArrayList<>();

public void addElement(final JavaClass clazz) {
vec.add(clazz);
Expand All @@ -43,6 +44,11 @@ public JavaClass elementAt(final int index) {
return vec.get(index);
}

@SuppressWarnings("unused") // SE_TRANSIENT_FIELD_NOT_RESTORED
private void readObjectNoData() {
vec = new ArrayList<>();
}

public void removeElementAt(final int index) {
vec.remove(index);
}
Expand Down

0 comments on commit 2df0926

Please sign in to comment.